【发布时间】:2014-12-23 14:17:47
【问题描述】:
我有这个片段:
<h:form id="form">
<!-- other content -->
<p:panel id="panel" header="test">
<p:inputText id="input1" value="#{viewScope.prop1}" required="true" />
<p:commandButton id="button1" process="@form" update="@form @widgetVar(dialog)"
oncomplete="PF('dialog').show()" value="ok" />
</p:panel>
<!-- other content -->
</h:form>
<p:dialog id="dialog" header="dialog" widgetVar="dialog" modal="true">
<h:form id="form2">
<p:inputText id="input2" value="#{viewScope.prop1}" required="true" />
<p:commandButton id="button2" process="@form" update="@form" value="ok" />
</h:form>
</p:dialog>
一切都按预期工作。
我想要实现的是:
<h:form id="form">
<!-- other content -->
<!-- fragment start -->
<!-- this fragment will be on its own file and included via ui:include (or inside composite component) -->
<p:panel id="panel" header="test">
<p:inputText id="input1" value="#{viewScope.prop1}" required="true" />
<p:commandButton id="button1" process="@form" update="@form @widgetVar(dialog)"
oncomplete="PF('dialog').show()" value="ok" />
</p:panel>
<p:dialog id="dialog" header="dialog" widgetVar="dialog" modal="true" appendTo="@(body)">
<h:form id="form2">
<p:inputText id="input2" value="#{viewScope.prop1}" required="true" />
<p:commandButton id="button2" process="@form" update="@form" value="ok" />
</h:form>
</p:dialog>
<!-- fragment end -->
<!-- other content -->
</h:form>
但我没有成功地尝试将process 和update 组合为button1 导致处理任何事情...input1 甚至正在重置...
那么,如何构建一个p:dialog,它可以在片段或复合组合中传送,而从form 外部排除?
注意使用:
<h:form id="form">
<!-- other content -->
<ui:include src="panel.xhtml" />
<!-- other content -->
</h:form>
<ui:include src="dialog.xhtml" />
不是一个可接受的解决方案。
我正在使用 JSF 2.2.8 (mojarra) 和 PF 5.1
【问题讨论】:
-
我想以 开头包含并以
-
不,这是不允许的 :) 但是我并没有试图避免嵌套表单,我试图在 appendTo 属性的帮助下使它们工作。根据 PF 对话框文档,这应该是可能的。
-
但是嵌套表单不是给您带来麻烦吗?我一直希望它不会通过 appendTo 在输出的 html 中嵌套。 primefaces 论坛上有一些关于它的讨论,也许你可以在那里找到一些东西
-
尝试使用表单名称而不是@form
-
Can you nest html forms? 的可能重复项
标签: jsf primefaces dialog nested-forms jsf-2.2