0

In my example, the bean paisMB opens a dialog with a datatable for the user search a object. In the bean portoMB I have the controller of a crud that uses the object searched in the paisMB.

The code below works, but it does not update the inputText, the update of the <p:ajax> execute before the onsuccess. How can I update the inputText?

<p:inputText id="pais" label="País" value="#{paisMB.paisSelecionado.nome}" required="true" readonly="true" />
<p:commandButton icon="fa fa-search" actionListener="#{paisMB.openPaisDialog}" >
    <p:ajax event="dialogReturn" update="panel" 
        listener="#{paisMB.onPaisChosenFromDialog}"
        onerror="#{portoMB.portoSelecionado.setPais(null)}"
        onsuccess="#{portoMB.portoSelecionado.setPais(paisMB.paisSelecionado)}" />
</p:commandButton>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Gleison
  • 192
  • 12
  • 1
    This is a duplicate to your technical problem, but not to your concrete requirement: http://stackoverflow.com/q/29096643 Is it in any case helpful? – BalusC Feb 01 '16 at 20:48

1 Answers1

0

BalusC showed me an answer that fixes my problem.

The following is the modified code:

<p:commandButton icon="fa fa-search" actionListener="#{paisMB.openPaisDialog}" >
    <p:ajax event="dialogReturn" listener="#{paisMB.onPaisChosenFromDialog}"
        onerror="setPaisNull()" onsuccess="setPaisObj()" />
    <p:remoteCommand name="setPaisObj" update="panel" action="#{portoMB.portoSelecionado.setPais(paisMB.paisSelecionado)}" />
    <p:remoteCommand name="setPaisNull" update="panel" action="#{portoMB.portoSelecionado.setPais(null)}" />
</p:commandButton>
Community
  • 1
  • 1
Gleison
  • 192
  • 12