how to set an objects string field to a jsf listbox -
in jsf backing bean have defined value as,
private list<cite> cites = new arraylist<cite>(); and cite has string like
cite { private string value; } jsf code
<h:panelgroup> <h:outputtext value="cite"/> <h:inputtext id="citetxt" style="width:75px" value="#{manualdataentryregtext.cite}"> <f:ajax execute="@this" render="citetxt" /> </h:inputtext> </h:panelgroup> <h:panelgroup> <h:commandbutton value="add" action="#{manualdataentryregtext.editcite}"> <f:ajax execute="@this" render="dtcites" /> </h:commandbutton> </h:panelgroup> <h:panelgroup> <h:selectmanylistbox style="width:75px" id="dtcites" value="#{manualdataentryregtext.cites}" var="cite" size="3"> <c:selectitems id="citeselectitems" value="#{cite.value}" /> <c:ajax event="change" /> </h:selectmanylistbox> </h:panelgroup>
modify list of follows:
<h:selectmanylistbox style="width:75px" id="dtcites" value="#{manualdataentryregtext.cites}" size="3" converter="citeconverter" ...> <f:selectitems value="#{citebean.allcites}" var="cite" itemlabel="#{cite.value}" itemvalue="#{cite}" /> </h:selectmanylistbox> and don't forget create , add @facesconverter cite class (basic example can found in mkyong's tutorial) or bind values (value of listbox , itemvalue of select items) plain strings.
Comments
Post a Comment