0

I have two command buttons, one edits a user and one adds a user, so the backing bean methods are slightly different. The syntax for the actual buttons are virtually the same, yet after one completes, the component updates, but the other does not. Can somebody explain the issue?

Button 1 (Works):

<p:dialog header="..." id="editUserDialog" widgetVar="editUserDialog" modal="true" appendTo="@(body)" draggable="false">
    <h:form id="editUserForm">
        <p:commandButton update=":form:tabs:adminView:userTable" value="submit" id="EditUserSubmitButton" actionListener="#{usersView.editUserRole}" oncomplete="PF('editUserDialog').hide();" />
    </h:form>
</p:dialog>

Button 2 (Not Working):

<p:dialog header="..." id="addUserDialog" widgetVar="addUserDialog" modal="true" appendTo="@(body)" draggable="false">
    <h:form id="addUserForm">
        <p:commandButton update=":form:tabs:adminView:userTable" value="submit" id="AddUserSubmitButton" actionListener="#{addUserView.submit}" oncomplete="PF('addUserDialog').hide();" />
    </h:form>
</p:dialog>

Thanks in advance.

James
  • 1,471
  • 3
  • 23
  • 52
  • can you share more code about your page.. – ankush yadav Jul 04 '16 at 12:20
  • where are they placed? the actionListener is different, maybe there is a java error on the second one ? – Fseee Jul 04 '16 at 12:57
  • @Franky they aren't nested inside another form if thats what you mean. I originally thought that but I've debugged it through and there appears to be no errors and its required functionality works behind the scenes. If I switch page and come back, the change is displayed, but the AJAX request just doesn't seem to work. – James Jul 04 '16 at 13:15
  • post complete code if possible – Fseee Jul 04 '16 at 13:22
  • @Franky: better to ask for [mcve] instead of just 'complete code'. See also http://www.stackoverflow.com/tags/jsf/info – Kukeltje Jul 04 '16 at 19:03
  • The buttons are identical, but is the rest? Check http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked – Kukeltje Jul 04 '16 at 19:05
  • Do you load the `user` list once and keep a copy of it in your bean? If so, make sure to reload the list after adding a new user. See http://stackoverflow.com/a/25632456/1980659 . – ForguesR Jul 06 '16 at 16:13
  • 1
    @ForguesR thanks for your help - you made me question what I was doing and realised I indeed wasn't reload my list when adding a new user, I was updating the database, but not the bean. The bean was only getting called on the initial loading of the application. Thanks a lot! – James Jul 12 '16 at 08:25

0 Answers0