4 Replies Latest reply on Dec 15, 2010 7:51 AM by Thando Madida

    Empty dropdown list

    Thando Madida Newbie

      Hoping someone will be able to assist.
      I'm not sure if I'm missing something, my dropdown list is empty, although if I use h:outputText the course name do display.

      Any help will be much appreciated.

      Here's a snippet of both my bean and jsf.
      public ArrayList<HashMap<String, Object>> getCourseList() throws Exception
        Integration ig = (Integration)Component.getInstance("integration");
        if (ig != null)
          HashMap localHashMap;
          ArrayList resList = ig.getList("CourseDetails", "select ed from CourseDetails ed");
          System.out.println("The length of the List is " + resList.size() + " Elements");
          for (Iterator localIterator = resList.iterator(); localIterator.hasNext(); localHashMap = (HashMap)localIterator.next());
          return resList;
          System.out.println("!Unable to get integration component!");
        return null;


      <h:selectOneMenu value="#{studentHome.instance.fkCourseDetails}">

        <a4j:repeat id="courseList" value="#{studentList.courseList}" var="course">

          <f:selectItems itemValue="#{course.get('fkCourse')}" itemLabel="#course.get('courseName')}" />


      Thanking you in advance

        • 1. Re: Empty dropdown list
          Christoph Kraus Newbie

          Hi Thandos,

          I think something like this should work...

          <a4j:repeat id="courseList" value="#{studentList.courseList}" var="course">
              <f:selectItem itemLabel="#{course.getKey()}" itemValue="#{course.getValue()}"/>

          Iterating through a HashMap returns objects of the type

          java.util.Map.Entry<K, V>

          Best regards,

          • 2. Re: Empty dropdown list
            Thando Madida Newbie

            Thank you Chris for your response.

            I tried what you suggested, but to no avail.

            Honestly don't know if i'm doing something wrong.

            Funny thing is if I move a4j:repeat outside h:selectOneMenu, then i get multiple dropdown lists and each showing individual courseNames

            Thanking you in advance

            • 3. Re: Empty dropdown list
              Martin Frey Newbie

              Hi Thandos
              Can you not use the f:items tag and call a function which returns you a list of select items? I've always used this approach to have dynamic select values. If you work directly with entities i use normally the s:items tag.

              Something like this:

              <h:selectOneMenu id="selectValue" value="#{action.type}">
                   <f:selectItems value="#{actionTypeListItems}" />

                    * Gets the action type list items.
                    * @return the action type list items
                   @Factory(value = "actionTypeListItems", scope = ScopeType.APPLICATION)
                   public List<SelectItem> getActionTypeListItems() {
                        List<SelectItem> result = new ArrayList<SelectItem>();
                        result.add(new SelectItem(null, "Select an action type"));
                        result.add(new SelectItem(ActionType.CORRECTIVE));
                        result.add(new SelectItem(ActionType.PREVENTIVE));
                        return result;

              • 4. Re: Empty dropdown list
                Thando Madida Newbie

                Hi Martin

                I also tried returnig SelectItem, but it still made no change.

                Just to add on...

                I have two databases

                Course (entity CourseDetails, fields - pkCourse, courseName)and
                Student (entity StudentDetails, fields - pkStudent, studentName, fkCourse),entities where generated using seam-gen.

                export both course and student as two separate war files. I've managed to get them to communicate with each other through services and ESB.
                Now in student jsf I've created a dropdown for fkCourse to display courseNames, but in my case it shows nothing.

                Hope it's a bit clear as to what I'm trying to do.

                If there is an alternative workaround to what I'm trying to achieve, it will be appreciated.

                Thanking you in advance