可能重复:
JSF ajax commandbutton not updating primefaces picklist
我正在使用primefaces p:dataTable和celleditor以及p:commandLink。 p:commandLink不会调用actionListener方法。但是,如果我使用普通的jsf h:commandButton它会调用。 这是我的jsf代码:
<h:form id="form">
<p:dataTable var="parent" value="#{adminView.parentlist}" id="parentlist" paginator="true" rows="10" paginatorAlwaysVisible="false" editable="true" styleClass="dtable" style="table-layout: fixed; width: 500px">
<p:column headerText="Nameр" style ="width: 40%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{parent.orgname}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{parent.orgname}" style="width: 100%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Edit" style="width: 10%">
<p:rowEditor/>
</p:column>
<p:column headerText="Delete" style="width: 10%">
<p:commandLink onclick="return confirm('Are you sure?')" value="del" actionListener="#{adminView.userOrgRemoveSelected}" styleClass="ui-icon ui-icon-trash" immediate="true">
<f:param name="id" value="#{parent.uorgId}"/>
<f:ajax execute =":form:userlist" render="parentlist :form:selectparent :form:selectparent1 :form:userlist"/>
</p:commandLink>
</p:column>
</p:dataTable>
</h:form>
这是我的bean代码:
public void userOrgRemoveSelected(ActionEvent action){
FacesContext fc = FacesContext.getCurrentInstance();
Map<String, String> params = fc.getExternalContext().getRequestParameterMap();
int id= Integer.parseInt(params.get("id"));
try {
UserOrganization uorg = userService.getUserOrgById(id);
userService.removeUserOrganization(uorg);
} catch (UserException ex) {
ex.printStackTrace();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Not possible to delete user"));
}finally{
this.parentlist = getUserOrganizationParents();
this.branchlist = getUserOrganizationBranches();
this.userlist = getUser1s();
}
}