java - About a checkbox on datatable -
i want use checkbox on datatable :
<h:selectbooleancheckbox styleclass="selectbooleancheckbox" valuechangelistener="#{completedinventoriesbean.changeuid}" value="#{completedinventoriesbean.ischecked(userinventorieswithuser.id)}" id="chkuser"> <f:ajax event="change" process="chkuser"></f:ajax> </h:selectbooleancheckbox>
my uids on session. , want user clicks checkbox , adding or removing ids on session.
there no problem, handle values on session beans.
but during click on checkboxes, javascript alert below:
servererror: class javax.faces.component.updatemodelexcepton/sections/completed.xhtml @29,244 value="#{completedinventoriesbean.ischecked(userinventorieswithuser.id)}": property 'ischecked' not found on type main.com.brad.services.completedinventoriesbean
my ischecked method :
public boolean ischecked(int z) { boolean exist = false; for(int i=0; < selectedsessionui.getsessioninventories().size(); i++) { if (selectedsessionui.getsessioninventories().get(i) == z) exist = true; } return exist; }
why alert? think stucked in page.
thanks in advance
you can't bind value
attribute method taking arguments. should bound property represented pure getter , setter.
in particular case, you'd rather use map<long, boolean>
instead.
private map<long, boolean> checked = new hashmap<long, boolean>(); @postconstruct public void init() { (int id : selectedsessionui.getsessioninventories()) { checked.put(long.valueof(id), true); } } public map<long, boolean> getchecked() { return checked; }
in combination with
<h:selectbooleancheckbox value="#{completedinventoriesbean.checked[userinventorieswithuser.id]}">
to collect checked rows, loop through checked
map in action method.
(no setter required since []
use put()
, get()
on map
itself)
Comments
Post a Comment