0

I have created a list of elements with two buttons. The first is "accept", the other is "decline". Whichever button I press, I want it to be removed from my datatable and have my list updated without the removed element. My problem is that my list cannot be updated quickly enough, so I have to wait one second.

<p:commandButton value="Accept" update="mydatatable"
                            <f:setPropertyActionListener value="#{mymessage}"
                                target="#{myView.accept}" />
                        </p:commandButton>

My view. accept

TimeUnit.SECONDS.sleep(1);
                FacesContext.getCurrentInstance().addMessage(null,
                        new FacesMessage(FacesMessage.SEVERITY_INFO, "element removed", ""));

What I want to do: execute the update once MyView.accept() is completely finished. I tried to change update by oncomplete/on success but I didn't get any satisfying result. I m looking for something like oncomplete = update="mydatatable"

How could I do that ?

Kukeltje
  • 11,924
  • 4
  • 19
  • 44
Jean
  • 521
  • 6
  • 17
  • Possible duplicate of [Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes](https://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes) – Mohammad Mar 19 '18 at 16:16
  • Thanks for your link – Jean Mar 19 '18 at 16:57

1 Answers1

0

Even if the message is not published anymore, someone gave the almost right answer to my problem (which helped me a lot,thanks)

the right answer was update="@this,mydatatable"

Jean
  • 521
  • 6
  • 17
  • And how does this remove the button from the datatable? – Kukeltje Mar 19 '18 at 17:06
  • The buttons are displayed in every row of the datatable. When the list is updated, the element is not part of the list anymore and its buttons are gone too. – Jean Mar 19 '18 at 17:13
  • But then there is no need to `update="@this"`.... Unless you have some other problem for which this is a workaround... (http://www.xyproblem.info) – Kukeltje Mar 19 '18 at 17:26