0 Replies Latest reply on Jan 2, 2006 9:15 PM by Teck Tchieng Wong

    Problem with JSF selectItems getting Collection object, wher

    Teck Tchieng Wong Newbie


      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}" />

      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

      Please help me solve my problem.

      Thank you.