java - Primefaces selectManyCheckbox -
i have selectmanycheckbox, cant checked values after change event (list of selected values stay empty). change event triggered in debug mode there no values in listselectedsignalcauses. tried set converter didnt either (maybe wrong converter).
<p:selectmanycheckbox value="#{signalanalysisbean.listselectedsignalcauses}" layout="pagedirection" styleclass="lstsignal"> <f:selectitems value="#{signalanalysisbean.listsignalcauses}" var="causes" itemvalue="#{causes}" itemlabel="#{causes.name}" /> <p:ajax process="@this" update="test" event="change" listener="#{signalanalysisbean.checkcauseslist}" /> </p:selectmanycheckbox> <h:outputtext value="#{signalanalysisbean.arrsize}" id="test" />
public class signalanalysisbean extends abstractbean { private list<generalcolldto> listsignalcauses; private list<generalcolldto> listselectedsignalcauses; //... public void checkcauseslist(){ arrsize = 4 + listselectedsignalcauses.size(); } //... } public class generalcolldto { private string name; private string value; public generalcolldto() { } public generalcolldto(string n, string v) { this.name = n; this.value = v; } public string getname() { return name; } public void setname(string name) { this.name = name; } public string getvalue() { return value; } public void setvalue(string value) { this.value = value; } }
in order send custom object managed bean need implement converter, otherwise not able that. code below implements based on code , may solution problem.
@facesconverter(value = "generalcolldtoconverter", forclass = generalcolldtoconverter.class) public class generalcolldtoconverter implements converter { @override public object getasobject(facescontext ctx, uicomponent component, string value) { if (value != null) { return component.getattributes().get(value); } return null; } @override public string getasstring(facescontext ctx, uicomponent component, object value) { if (value != null && value instanceof generalcolldto) { generalcolldto generalcolldto = (generalcolldto) value; if (generalcolldto.getname() != null) { component.getattributes().put(generalcolldto.getname(), value); return generalcolldto.getname(); } } return null; } } <p:selectmanycheckbox converter="generalcolldtoconverter" value="#{signalanalysisbean.listselectedsignalcauses}" layout="pagedirection" styleclass="lstsignal">
Comments
Post a Comment