PickList reference problem
z8rasmus Dec 12, 2010 9:20 AMHello There!
I'm having some troubles with the RichFaces PickList. I managed to set it in a JSP page, and it seems to work. the problem is when i choose to move an item from one column to the other I can't. when i debug I see that the item i pass is passed as some string-representation of the actual object.
This is my code:
<rich:pickList value="#{ContentBean.myContents}"><%--UserBean.hobbyNames--%>
<f:selectItems value="#{ContentBean.allContents}"
</rich:pickList>
public class ContentBean {
List<SelectItem> allContents = new ArrayList<SelectItem>();
List<content> myContents = new ArrayList<content>();
public ContentBean(){
content c1 = (new content("name1", "info1"));
content c2 = (new content("name2", "info2"));
content c3 = (new content("name3", "info3"));
content c4 = (new content("name4", "info4"));
allContents.add(new SelectItem(c1, c1.getName()));
allContents.add(new SelectItem(c2, c2.getName()));
allContents.add(new SelectItem(c3, c3.getName()));
allContents.add(new SelectItem(c4, c4.getName()));
myContents.add(c2);
myContents.add(c3);
}
public List<content> getMyContents() {
return myContents;
}
public void setMyContents(List<content> newContents) { NewContents holds: "Content.content@16127" "Content.content@917287"
this.myContents = newContents;
String name = myContents.get(1).getInfo(); <--this throws an error because newContents doesnt hold object but references
}
public List<SelectItem> getAllContents() {
return allContents;
}
public void setAllContents(List<SelectItem> allContents) {
this.allContents = allContents;
}
I get errors like this:
12-12-2010 15:13:03 org.ajax4jsf.context.AjaxContextImpl convertId
WARNING: Target component for id result not found
12-12-2010 15:13:03 com.sun.faces.lifecycle.RenderResponsePhase execute
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=j_id_jsp_1315124744_1:j_id_jsp_1315124744_3[severity=(ERROR 2), summary=(/welcomeJSF.jsp(25,8) '#{ContentBean.myContents}' Error writing 'myContents' on type Content.ContentBean), detail=(/welcomeJSF.jsp(25,8) '#{ContentBean.myContents}' Error writing 'myContents' on type Content.ContentBean)]
Can anyone help me?