jsf - PrimeFaces ManyCheckbox ArrayList not Updating inside modal dialog -
this question has answer here:
i have modal dialog, user can select , deselect roles based on user , submit database updated.
however, after debugging, arraylist
backs manycheckbox
doesn't updated, , selectedroles
arraylist
remains was.
for example:
i load application
there 1 user in database role 'admin'
i try edit user , dialog opens up, 'admin' checkbox selected.
i click 'user' role checkbox , click submit
the selectedroles array still 'admin' instead of 'admin' , 'user'
here dialog modal:
<p:dialog header="editing user id: #{usersview.viewuser}" id="edituserdialog" widgetvar="edituserdialog" modal="true" appendto="@(body)"> <h:form id="edituserform"> <p:selectmanycheckbox id="roleselect" value="#{usersview.selectedroles}" layout="grid" columns="3"> <f:selectitems value="#{rolesview.roles}" var="role" itemlabel="#{role.name}" itemvalue="#{role.name}" /> </p:selectmanycheckbox> <p:separator /> <p:commandbutton process="@this" update=":form:tabs:adminview:usertable:userroleoutput" value="submit" id="editusersubmitbutton" actionlistener="#{usersview.edituserrole}" oncomplete="pf('edituserdialog').hide();" /> </h:form> </p:dialog>
userview:
@managedbean(name="usersview", eager=true) @applicationscoped private arraylist<string> selectedroles; public arraylist<string> getselectedroles() { return this.selectedroles; } public void setselectedroles(arraylist<string> roles) { this.selectedroles = roles; } public void edituserrole(actionevent actionevent) { // method literally loops through users , matches 1 we're looking @ user user = finduser(); if (user != null) { // gives user checked roles in database , local session addselectedroles(user); arraylist<string> rolestoremove = user.getrolenames(); rolestoremove.removeall(selectedroles); // removes user unchecked roles in database , local session removeselectedroles(user, rolestoremove); } else { // handle exception... } }
i working on restricted vm, cannot copy , paste , information can post, believe enough.
any appreciated.
i solved issue removing process="@this"
, arraylist getting updated.
process="@this"
means current component of commandlink , hence why wasn't updating.
Comments
Post a Comment