Hi Jakob, Your way of initializing and populating goups in getGroups() methods worked - thank you very much indeed.
With regards, Damar On Sat, Jan 2, 2010 at 10:52 PM, Jakob Korherr <[email protected]>wrote: > Hi Damar, > > It seems like somehow #{choice.groups} resolves to null. > > I don't really know why, but you can try to debug your app and look at the > value of groups. Either some part of your code sets groups to null or it is > not initialised at all. > > In your case, I would write Choice.java in the following way: > > public class Choice { > private List<SelectItem> groups; > > public Choice() { > } > > public List<SelectItem> getGroups() { > if (groups == null) > { > groups = new ArrayList<SelectItem>(); > groups.add(new SelectItem(1,"Test")); > groups.add(new SelectItem(2,"Test1")); > } > return groups; > } > > public void setGroups(List<SelectItem> groups) { > this.groups = groups; > } > > } > > Regards, > Jakob > > 2010/1/2 Damar Thapa <[email protected]> > > > Hi, > > > > I am trying to create a selctOneMenum, and I have the following snapshot > of > > xhmtl file: > > > > <t:selectOneMenu value="#{libraryUser.group}"> > > <f:selectItems value="#{choice.groups}"/> > > </t:selectOneMenu> > > > > Choice.java (choice.groups) is as follows: > > > > public class Choice { > > private List<SelectItem> groups=new ArrayList<SelectItem>(); > > > > public Choice() { > > groups.add(new SelectItem(1,"Test")); > > groups.add(new SelectItem(2,"Test1")); > > } > > > > public List<SelectItem> getGroups() { > > return groups; > > } > > > > public void setGroups(List<SelectItem> groups) { > > this.groups = groups; > > } > > > > } > > > > I, however, is getting error message: > > > > Caused by: java.lang.IllegalArgumentException: Value binding > > '#{choice.groups}'of UISelectItems with component-path {Component-Path : > > [Class: javax.faces.component.UIViewRoot,ViewId: > > /pages/userInput.xhtml][Class: javax.faces.component.html.HtmlForm,Id: > > helloForm][Class: javax.faces.component.html.HtmlPanelGrid,Id: > > j_id8][Class: > > org.apache.myfaces.component.html.ext.HtmlSelectOneMenu,Id: > j_id19][Class: > > javax.faces.component.UISelectItems,Id: j_id20]} does not reference an > > Object of type SelectItem, SelectItem[], Collection or Map but of type : > > null > > at > > > > > org.apache.myfaces.shared_tomahawk.util.SelectItemsIterator.hasNext(SelectItemsIterator.java:166) > > > > From the error message, it sounds like groups does not have SelectItem > > object, and I am missing something. I appreciate if somebody can provide > me > > some pointers. > > Thanks, > > With regards, > > Damar > > > -- With regards, Damar

