I have the page below, everything works fine…
Except that after I click the delete button and hit “Yes Sure” in the Confirm Dialog My page doesn’t change… It should show me the same form without that user.
I tryed a lot of things, but I am using Primefaces 3.0.M3
My form table is server created so it should be ajax usable.
Anyone got an idea what is wrong ?
Thanks !
<h:form id="main" prependId="false">
<p:dataTable var="user" value="#{userController.allUsers}" id="userTable">
<p:ajax event="rowEdit" update="@this" listener="#{userController.onEditRow}" />
<f:facet name="header">
#{bundle.ListOfUsers}
</f:facet>
<p:column headerText="#{bundle.USERNAME}" style="width:110px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{user.name}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{user.name}" style="width:110%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{bundle.Login}" style="width:100px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{user.login}" />
</f:facet>
<f:facet name="input">
<h:outputText value="#{user.login}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{bundle.Roles}" style="width:180px;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{user.rolesCollection}"/>
</f:facet>
<f:facet name="input">
<p:selectManyMenu value="#{user.rolesCollection}"
converter="rolesConverter"
style=" width:100%;">
<f:selectItems value="#{roleController.listOfRoles}"
var="roles"
itemLabel="#{roles.rolename}"
itemValue="#{roles}"
/>
</p:selectManyMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{bundle.edit}" style="width:10px; overflow:visible;">
<p:rowEditor/>
</p:column>
<p:column headerText="#{bundle.delete}" style="width:10px; overflow:visible;">
<p:commandButton update=":main" oncomplete="confirmation.show()" image="ui-icon ui-icon-close" title="Delete" >
<f:param value="#{user.id}" name="userAction" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:confirmDialog message="Are you sure? user:#{param['userAction']} " width="500"
header="Confirm" severity="alert" widgetVar="confirmation" >
<p:commandButton value="Yes sure" update="userTable" actionListener="#{userController.deleteAction( param['userAction'])}" oncomplete="confirmation.hide()" >
<f:param name="userAction" value="#{param['userAction']}" />
</p:commandButton>
<p:commandButton value="Not yet" onclick="confirmation.hide()" type="button" />
</p:confirmDialog>
</h:form>
Here is the controller method
public void deleteAction(String id){
userFacade.remove(userFacade.find(Integer.parseInt(id)));
}
This method is being called and it’s deleting the user.
You need to reload the
allUserslist in the bean’s action method after deleting the user.Otherwise JSF will just retrieve the original list. You’re apparently prepopulating the list in the (post)constructor of a view scoped bean, that’s why a F5 works.