我正在使用 PF 3.5 和 JSF Mojarra 2.1。
我有一个对话框,我想使用 appendToBody=true。不过,这通常会导致“不可预测的行为”。
基本上对话框的作用是,当我从数据表中选择一个条目(一个 persn 实体)时,它会为我提供可以编辑的填充输入框,从而编辑特定条目(人员详细信息)。
有时输入框会正确填充条目数据。有时他们不这样做。
appendToBody=false 不会发生此行为。
除此之外,我很确定没有嵌套表单。
正如您会注意到的,我正在尝试使用纯 ajax 导航的“单页设计”。
主页 (index.xhtml)
<h:body>
<pe:layout id="page" fullPage="true">
<!-- North -->
<pe:layoutPane id="north" position="north" minSize="140"
closable="true" resizable="false">
....
</pe:layoutPane>
<!-- West -->
<pe:layoutPane id="west" position="west" minWidth="150" size="180"
style="font-size: 14px !important;" closable="true"
styleClassHeader="menuBar" resizable="false">
<f:facet name="header">Main Menu</f:facet>
<h:form id="form1">
<p:panelMenu id="panelMenu" style="width: 160px !important">
<!-- On menu click update with Ajax centerpanel and msgPanel -->
<p:submenu label="Persons" style="font-size: 10px ">
<p:menuitem value="Person List" update=":centerpanel"
actionListener="#{layout.setAll('formPersonList.xhtml', 'Person List')}"
action="#{person.init()}">
</p:menuitem>
</p:submenu>
.....
</p:panelMenu>
</h:form>
</pe:layoutPane>
<!-- Center -->
<pe:layoutPane id="content" position="center"
style="font-size: 14px !important" styleClassHeader="menuBar">
<h:panelGroup id="centerpanel" layout="block">
<ui:include id="include" src="#{layout.navigation}" />
</h:panelGroup>
</pe:layoutPane>
</pe:layout>
该对话框位于文件 formPersonList.xhtml 中并且位于表单之外
<ui:composition ....>
<h:form id="mainForm">
<p:contextMenu for="personTable">
<p:menuitem value="View Details"
process="@form" actionListener="#{person.handleSelectedPerson()}"
update=":dlgPersonGrp"
oncomplete="dlgPerson.show();">
</p:menuitem>
</p:contextMenu>
<p:dataTable id="personTable ....>
....person entities
</p:dataTable>
</h:form>
<p:dialog widgetVar="dlgPerson" showEffect="size"
width="1100" appendToBody="true">
<h:panelGroup id="dlgPersonGrp">
<ui:include src="formPerson.xhtml" />
</h:panelGroup>
</p:dialog>
</ui:composition>
最后,带有输入框的表单:formPerson.xhtml
<ui:composition ....>
<h:form id ="subForm">
....Input boxes that are supposed to be filled up from a backing bean
and then resubmitted to edit the chosen entry
</h:form>
</ui:composition>
我试图尽可能地把它弄糊涂。如果您需要更多详细信息,请告诉我。
最佳答案
我知道这是一个老问题,但我在使用 Primefaces 5 时遇到了同样的问题。
解决方案很简单,我在标签中包含了属性 appendTo="@(body)"。
<p:dialog header="Title" widgetVar="dlg" modal="true" appendTo="@(body)">
<h:outputText value="Dialog text..." />
<p:commandButton value="Ok" onclick="PF('dlg').close()" />
</p:dialog>
关于jsf - PrimeFaces Dialog + appendToBody=true 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18607921/