p:dialog form submit loses action method after RequestContext update

允我心安 提交于 2019-12-29 09:57:20

问题


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()?

来源:https://stackoverflow.com/questions/31350850/pdialog-form-submit-loses-action-method-after-requestcontext-update

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!