Jsf p:RequestContext更新后对话框表单提交丢失操作方法
我的Jsf p:RequestContext更新后对话框表单提交丢失操作方法,jsf,primefaces,Jsf,Primefaces,我的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: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>
我逐渐意识到,只有当我更新对话框(上面中间的一行)时,才会发生此故障。如果我实际上不这样做(这对于对话框功能来说并不重要,但标题显示为空),则提交操作可以正常工作。因此,上下文更新似乎把事情搞砸了,我不知道如何在保留提交功能的同时获得这两个更新。这可能是
RequestContext.update()
中的一个bug吗?我已经用你的代码做了一个MCVE,它工作得很好。我有一个p:commandButton
和一个actionListener
,用于调用Java代码(使用context.update
)。这段代码完美地更新了文本标题,并显示了对话框。当我按下Submit
按钮时,将调用对话框formsubmit
。如果您愿意,我可以在回答中发布我的代码。作为补充说明,componentId和widgetVar不应该有相同的名称为什么是@EmilKaminski?下面是一个很好的解释:
RequestContext context = RequestContext.getCurrentInstance();
context.update("commentDialog");
context.execute("PF('commentDialog').show();");