1 Reply Latest reply on Jul 24, 2007 5:28 PM by Brian Smith

    Dependable dropdowns (Seam way)

    mgrouch Expert

      What is the best way to implement dependable dropdowns with Seam?
      (set of values in one depends on the other, full set of values in second one
      is too big to do it all client side)


        • 1. Re: Dependable dropdowns (Seam way)
          Brian Smith Apprentice

          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"
           <s:selectItems label="#{landType.landmarkTypeDescription}"
           noSelectionLabel="(None)" var="landType"/>
           <a4j:support event="onchange"
           ajaxSingle="true" reRender="landmark_input"/>
           <h:selectOneMenu id="landmark_input" value="#{landmark}">
           <s:selectItems label="#{land.landmarkName}"
           noSelectionLabel="(None)" var="land"/>

          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.

           private LandmarkType landmarkType;
           List<Landmark> landmarkList;
           public void fillLandmarkList() {
           if (!(entityManager.contains(landmarkType))) {
           landmarkType = entityManager.getReference(LandmarkType.class, landmarkType.getLandmarkTypeId());
           landmarkList = (List) landmarkType.getLandmarkCollection();