[jboss-user] [JBoss Seam] - Re: Dependable dropdowns (Seam way)

smithbstl do-not-reply at jboss.com
Tue Jul 24 17:28:32 EDT 2007


I have used Ajax4JSF and seam to achieve this

here is an example  

I have a list of LandmarkTypes and a List of Landmarks that is dependent on the LandmarkType chosen


  |     <a4j:region selfRendered="true">
  | 	    <h:selectOneMenu id="landmarkType_id" 
  | 				value="#{landmarkType}">
  | 		<s:selectItems label="#{landType.landmarkTypeDescription}" 
  | 			value="#{allLandmarkTypes.resultList}" 
  | 		    noSelectionLabel="(None)" var="landType"/>
  | 		<s:convertEntity/>
  | 	<a4j:support event="onchange" 
  | 		actionListener="#{addressLocator.fillLandmarkList}" 
  | 		ajaxSingle="true" reRender="landmark_input"/>               
  | 	    </h:selectOneMenu>
  |     </a4j:region>
  |         
  |     <h:selectOneMenu id="landmark_input" value="#{landmark}">
  | 	    <s:selectItems label="#{land.landmarkName}" 
  | 		value="#{landmarkList}" 
  | 		noSelectionLabel="(None)" var="land"/> 
  | 	    <s:convertEntity/>                               
  |     </h:selectOneMenu>

The LandmarkTypes are filled using a CRUD entity-query ("allLandmarkTypes") but could just as easily be done using an @Factory method.

Here is the sfsb.  I am using lazy loading to fill the list but a query would work just as well.


  |     @In(required=false)
  |     private LandmarkType landmarkType;
  | 
  |     @Out(required=false)
  |     List<Landmark> landmarkList;
  | 
  |     public void fillLandmarkList() {
  | 	if (!(entityManager.contains(landmarkType))) {
  | 		landmarkType = entityManager.getReference(LandmarkType.class, landmarkType.getLandmarkTypeId());
  | 	}
  | 	landmarkList = (List) landmarkType.getLandmarkCollection();
  | 	          	
  |     } 


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067186#4067186

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067186



More information about the jboss-user mailing list