I have a dataTable which view rows of users. After selecting the checkbox on each row and click on Add button, another table should be updated with selected users. However, when debuging OrganizationUser in the setSelected, I can see that the ajax request value received for the checkbox was always "false", what could be possibly wrong here?
JSF Code:
<p:lightBox id="notf_user" style="width: auto;" rendered="true" widgetVar="usersDialog">
<h:outputLink value="#">
<h:outputText value="Add User" />
</h:outputLink>
<f:facet name="inline">
<p:dataTable id="xxx" var="user" tableStyle="width:auto" value="#{agreementWizard.agreementAvailableNotificationUsers}">
<f:facet name="header">
<p:outputLabel value="Users to be notified"/>
</f:facet>
<p:column headerText="User ID">
<h:panelGroup>
<h:outputText value="#{user.userId}" />
</h:panelGroup>
</p:column>
<p:column headerText="Name">
<h:panelGroup>
<br/>
<p:outputLabel value="Name: "/><h:outputText value="#{(user.firstNameEn).concat(' ').concat(user.lastNameEn)}" />
<br/>
<p:outputLabel value="Email: "/><h:outputText value="#{user.emailAddress}" />
<br/>
<p:outputLabel value="Mobile: "/><h:outputText value="#{user.mobileNum}"/>
<br/>
</h:panelGroup>
</p:column>
<p:column >
<p:selectBooleanCheckbox id="hish" value="#{user.selected}" >
<p:ajax update="xxx"/>
</p:selectBooleanCheckbox>
</p:column>
<f:facet name="footer">
<p:commandButton value="Close" onclick="hideNotificationUsersFD()">
<p:ajax update="selected_notifications_users" process="@this"/>
</p:commandButton>
</f:facet>
</p:dataTable>
</f:facet>
</p:lightBox>
OrganizationUser and AgreementWizard:
@ManagedBean
@ViewScoped
public class OrganizationUser implements Serializable{
private String userId;
private String emailAddress;
private String mobileNum;
private boolean selected;
*
*
*
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
}
@ManagedBean(name = "agreementWizard")
@ViewScoped
public class AgreementWizard {
private List<AgreementAccount> agreementSelectedAccounts;
private List<OrganizationUser> agreementSelectedNotificationUsers;
@PostConstruct
public void init(){
agreementSelectedNotificationUsers = new ArrayList<OrganizationUser>();
agreementAvailableNotificationUsers = new ArrayList<OrganizationUser>();
OrganizationUser user1 = new OrganizationUser();
agreementAvailableNotificationUsers.add(user1);
OrganizationUser user2 = new OrganizationUser();
agreementAvailableNotificationUsers.add(user2);
}
public List<OrganizationUser> getAgreementSelectedNotificationUsers() {
agreementSelectedNotificationUsers.clear();
for(OrganizationUser user : agreementAvailableNotificationUsers){
if(user.isSelected()){
agreementSelectedNotificationUsers.add(user);
}
}
return agreementSelectedNotificationUsers;
}
public void setAgreementSelectedNotificationUsers(List<OrganizationUser> agreementSelectedNotificationUsers) {
this.agreementSelectedNotificationUsers = agreementSelectedNotificationUsers;
}
}
Aucun commentaire:
Enregistrer un commentaire