1
votes

I have a Dialog and a CommandLink which shows this dialog. In this Dialog i display values which has created during the action (or propertyListener) of the command link. But because the update is executed before the action, the variables are not set.

<p:commandLink update="@form:myDialog" action="#{myBean.setText('text')}"
oncomplete="myDialog.show()">
</p:commandLink>
....
<p:dialog widgetVar="myDialog"  modal="true">
      <p:inputText value="#{myBean.text}" />
</p:dialog>

Is it possible to execute an action before the update is done?

2
Please post the stacktrace. - user1983983
I changed the description. There is no exception and no stacktrace. - jobe

2 Answers

1
votes

I dialog will update you haven't specified the Id attribute of the dialog

<p:commandLink update="myDialog" action="#{myBean.setText('text')}"
     oncomplete="myDialog.show()">
</p:commandLink>

<p:dialog Id="myDialog" widgetVar="myDialog"  modal="true">
    <p:inputText value="#{myBean.text}" />
</p:dialog>

This will help you .

But what i prefer is use an outputpanel

<p:commandLink update="myDialogPanel " actionlistner="#{myBean.setText('text')}"
     oncomplete="myDialog.show()">
</p:commandLink>

<p:dialog Id="myDialog" widgetVar="myDialog"  modal="true">
   <p:outputPanel Id=myDialogPanel >
    <p:inputText value="#{myBean.text}" />
   </p:outputPanel>
</p:dialog>

or you can update the dialog from managedBean and show the dialog. This is helpful if you get any error at your managedBean method your dialog is not show.

RequestContext.getCurrentInstance().update("myDialogPanel");
RequestContext.getCurrentInstance().execute("myDialog.show();");
1
votes

You can open the Dialog from ManagedBean itself.

RequestContext.getCurrentInstance().execute(myDialog.show());

RequestContext can be used to Execute any javascript from ManagedBean.
You can also update the components from Managed Bean using RequestContext's Update method.

 RequestContext.getCurrentInstance().update("COMPONENT_ID");