0 Replies Latest reply on Jan 2, 2006 9:15 PM by wongtt78

    Problem with JSF selectItems getting Collection object, wher

    wongtt78

      Hi,

      Regarding the subject matter above, when I open the JSP page that have the selectItems component looping the collection object, it generates error that says that the content of the Collection object is not instanceOf SelectItem.

      The collection object that I had mentioned was bundled in a JAR file and that JAR file was inside the root of the EAR file. Refer to the example below:

      Example no. 1

      public class Person{
       private String name;
       private String gender;
       private List gendersList;
      
       public String getName(){
       return this.name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       public String getGender(){
       return this.gender;
       }
      
       public void setGender(String gender) {
       this.gender= gender;
       }
      
       public List getGendersList(){
       gendersList = new ArrayList();
       genderList.add( new SelectItem("m", "Male", null) );
       genderList.add( new SelectItem("f", "Female", null) );
      
       return genderList;
       }
      }
      
      
      public class PersonBean extend Person{
       public String action(){
       < ...do action here... >
       }
      }
      
      ... in JSP ...
      <h:selectOneRadio id="gender" value="#{person.gender}">
       <f:selectItems value="#{person.gendersList}" />
      </h:selectOneRadio>
      
      


      Looking at example no. 1 above, the Person class was compiled and bundled into GuestBook.jar and the PersonBean class was compiled and copy into WEB-INF/classes. 'person' was a name for backing-bean PersonBean class. JSF libraries was in WEB-INF/lib.

      That sort of configuration will generate error that says that the content of the Collection object is not instanceOf SelectItem.

      I've tested the content of the Collection object (in PersonBean) and I successfully display it in System.out.println.

      If I move the getGendersList method into PersonBean, the JSP page load successfully.

      Example application.xml
      <application>
       <display-name>Project</display-name>
       <module>
       <java>GuestBook.jar</java>
       </module>
       <module>
       <web>
       <web-uri>guestbook.war</web-uri>
       <context-root>gb</context-root>
       </web>
       </module>
      </application>
      


      Please help me solve my problem.

      Thank you.