0

I have a small form inside my p:dialog:

<p:dialog id="commentDialog" header="#{managedBean.dialogHeader}" widgetVar="commentDialog" modal="true" resizable="true" height="auto">
    <h:form>
        <h:outputLabel for="comment" value="Comment:"/>

        <p:inputTextarea id="comment" title="Comment" 
                rows="6" cols="33"
                value="#{managedBean.comment}"
                required="true"/>
        <h:commandButton value="Submit" action="#{managedBean.dialogFormSubmit}"/>
    </h:form>
</p:dialog>

Can you tell why, when I hit the Submit button, the dialog does get closed but the dialogFormSubmit() in the managed bean does not get invoked?

I also tried changing to p:commandButton thinking the functionality required the PrimeFaces variant of the h:commandButton but got the same.

The question is similar to this and I tried to do the same but couldn't make it work and also this one which doesn't really seem to have a workable answer.

UPDATE:

The dialog was being shown from the managed bean but was also updated (the solution for which I got here) prior to showing by using the RequestContext API in order to refresh the header:

RequestContext context = RequestContext.getCurrentInstance();  
context.update("commentDialog");
context.execute("PF('commentDialog').show();");

I have come to realize that this malfunction occurs only when I update the dialog (middle line above). When I actually don't (which is not critical for the dialog functionality but the header appears blank), the submit action works fine. So the context update seems to be what's messing it up and I don't know how to get both the update while retaining the submit functionality. Could it be a bug in RequestContext.update()?

Community
  • 1
  • 1
amphibient
  • 25,192
  • 44
  • 130
  • 215
  • I've made a MCVE with your code and it works fine. I have a `p:commandButton` with a `actionListener` for calling your Java code (with `context.update`). This code updates the text header perfectly and show me the dialog. When I push over `Submit` button the `dialogFormSubmit` is invoked. If you want I can post my code in an answer. – Miguel Jul 13 '15 at 08:10
  • As a side note the componentId and widgetVar should not have the same name – Emil Kaminski Jul 13 '15 at 11:08
  • why is that, @EmilKaminski ? – amphibient Jul 13 '15 at 15:06
  • Here is a good explanation: http://stackoverflow.com/questions/19095787/using-the-component-id-as-widgetvar-name – Emil Kaminski Jul 14 '15 at 06:32

0 Answers0