Jsf PrimeFaces嵌套在p:dialog中,带appendTo="@(正文)
我有这个片段:Jsf PrimeFaces嵌套在p:dialog中,带appendTo="@(正文),jsf,primefaces,dialog,nested-forms,jsf-2.2,Jsf,Primefaces,Dialog,Nested Forms,Jsf 2.2,我有这个片段: <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="@f
<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>
这不是一个可接受的解决方案
我使用的是JSF2.2.8(mojarra)和PF5.1,在对话框中只使用一种形式。我干得不错
<h:body>
<h:form id="OneFormId">
<!-- Some content -->
</h:form>
<p:dialog id="MyDialogId" header="My Header Info"
widgetVar="MyWidgetVarName" modal="true" appendTo="@(body)">
<h:form id="MyFormId">
<p:outputPanel>
<p:messages id="MyMsgId" autoUpdate="true" />
<h:panelGrid columns="2">
<h:outputLabel for="usr" value="User:" />
<p:inputText id="usr" value="#{MyManageBeanName.MyProperty}"
required="true" requiredMessage="User is required." />
</h:panelGrid>
<p:separator />
<h:panelGrid columns="2">
<p:commandButton value="Save" id="MyBtnSaveId"
styleClass="ui-priority-primary" icon="ui-icon-circle-check"
process="@form" />
<p:commandButton value="Cancel" id="MyBtnCancelId"
onclick="PF('MyWidgetVarName').hide()"
styleClass="ui-priority-primary" icon="ui-icon-close"
process="MyBtnCancelId" />
</h:panelGrid>
</p:outputPanel>
</h:form>
</p:dialog>
<h:form id="OtherFormId">
<!-- Some content -->
</h:form>
最后,我找到了一种使用OmniFaces和
的方法:
第页:
因为对于回发,在后续的RESTORE\u视图中不会重新删除已恢复的组件
对于我的实验来说,这些警告是无害的,可以安全地忽略
但是,我打开了它,最终修复了它。我想以?开头并以?结尾是不可接受的:)在我看来,不管怎样,你都会得到嵌套的表单。不,这是不允许的:)然而,我并没有试图避免嵌套的表单,我只是试图让它们在appendTo属性的帮助下工作。根据PF dialog文档,这应该是可能的。但是嵌套表单不是给您带来麻烦吗?我一直希望它不会出现在通过appendTo输出的html中。primefaces论坛上有一些关于它的讨论,也许你可以在那里找到一些东西尝试使用表单名而不是@form可能重复的
<h:form id="form">
<!-- other content -->
<ui:include src="panel.xhtml" />
<!-- other content -->
</h:form>
<ui:include src="dialog.xhtml" />
<h:body>
<h:form id="OneFormId">
<!-- Some content -->
</h:form>
<p:dialog id="MyDialogId" header="My Header Info"
widgetVar="MyWidgetVarName" modal="true" appendTo="@(body)">
<h:form id="MyFormId">
<p:outputPanel>
<p:messages id="MyMsgId" autoUpdate="true" />
<h:panelGrid columns="2">
<h:outputLabel for="usr" value="User:" />
<p:inputText id="usr" value="#{MyManageBeanName.MyProperty}"
required="true" requiredMessage="User is required." />
</h:panelGrid>
<p:separator />
<h:panelGrid columns="2">
<p:commandButton value="Save" id="MyBtnSaveId"
styleClass="ui-priority-primary" icon="ui-icon-circle-check"
process="@form" />
<p:commandButton value="Cancel" id="MyBtnCancelId"
onclick="PF('MyWidgetVarName').hide()"
styleClass="ui-priority-primary" icon="ui-icon-close"
process="MyBtnCancelId" />
</h:panelGrid>
</p:outputPanel>
</h:form>
</p:dialog>
<h:form id="OtherFormId">
<!-- Some content -->
</h:form>
<h:form id="form">
<!-- other content -->
<ui:include src="/fragment/with/inner/form.xhtml" />
<!-- other content -->
</h:form>
<ui:composition>
<p:inputText id="outerText" value="#{viewScope.text}" />
<p:commandButton id="openButton" process="@form" update="@widgetVar(testDialog)"
oncomplete="PF('testDialog').show()" value="open" />
<o:moveComponent id="move" for=":#{facesContext.viewRoot.clientId}" destination="ADD_LAST">
<h:form id="innerForm">
<p:dialog id="dialog" widgetVar="testDialog" header="test dialog">
<p:inputText id="innerText" value="#{viewScope.text}" />
<f:facet name="footer">
<p:commandButton id="confirmButton" process="@form" update=":form"
oncomplete="if(!args.validationFailed) PF('testDialog').hide()"
value="submit" />
</f:facet>
</p:dialog>
</h:form>
</o:moveComponent>
</ui:composition>
WARNING Unable to save dynamic action with clientId 'form:innerForm:dialog' because the UIComponent cannot be found
WARNING Unable to save dynamic action with clientId 'form:innerForm:innerText' because the UIComponent cannot be found
WARNING Unable to save dynamic action with clientId 'form:innerForm:confirmButton' because the UIComponent cannot be found