2
votes

I open a Dialog using Primefaces dialog framework

RequestContext.getCurrentInstance().openDialog("myDialog", options, null);

Then, I want to update a component in the base page after the dialog's close event. I know we could add a 'dialogReturn' ajax event

<p:ajax event="dialogReturn" update = ":form:colors"  />

But how to do this programmatically using the dialog framework?

1
Have the same problem.. how to pass the ajax stuff to the openDialog()-Method - Kevin Busch

1 Answers

0
votes

Workaround:

assign the action to open the dialog to a button; with javascript call the click() method of that button and assign a dialogReturn to it:

public void openDialogWithJS(){
            RequestContext.getCurrentInstance().execute("$('#myForm\\\\:myButton').click()");
    }



public void showDialog(){
    RequestContext.getCurrentInstance().openDialog("myDialog", options, null);
}
<h:form id="myForm">
                <p:commandButton id="myButton" actionListener="#{myBean.showDialog}" style="display: none;">
                    <p:ajax event="dialogReturn"  update = "myComponentId"/>
                </p:commandButton>
</h:form>