PrimeFaces对话框+​​ appendToBody = true不起作用 [英] PrimeFaces Dialog + appendToBody=true not working

查看:157
本文介绍了PrimeFaces对话框+​​ appendToBody = true不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PF 3.5和JSF Mojarra 2.1.

I'm using PF 3.5 and JSF Mojarra 2.1.

我有一个对话框,我想使用appendToBody = true.不过,这通常会导致不可预测的行为".

I have a dialog which I want to use appendToBody=true. This usually results in "unpredictable behavior" though.

基本上,对话框的作用是,当我从数据表中选择一个条目(一个persn实体)时,它会给我填满我可以编辑的输入框,从而编辑特定的条目(人的详细信息).

Basically what the dialog does is, when I choose an entry (a persn entity) from a datatable, it gives me filled up input boxes which I can edit, thus editing the particular entry (person details).

有时输入框会被条目数据正确填充.有时他们不这样做. 使用appendToBody = false不会发生此行为. 除此之外,我很确定没有嵌套的表单.

Sometimes the input boxes get filled up properly with the entries data. Sometimes they dont. This behavior does not happen with appendToBody=false. Aside from that I'm pretty sure there are no nested forms.

您会注意到,我正在尝试使用纯ajax导航的一页设计".

As you will notice I am trying out a "One page design" with purely ajax navigation.

主页(index.xhtml)

Main page (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>

该对话框的文件格式为PersonList.xhtml,并且不在此格式

The dialog is in a file formPersonList.xhtml and is outside the form

<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

Finally, the form with the input boxes: 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>

我试图尽可能地将其静音.让我知道您是否需要更多细节.

I have tried to dumb it down as much as possible. Let me know if you need more detail.

推荐答案

我知道这是一个老问题,但是我在Primefaces 5中也遇到了同样的问题. 解决方案很简单,我在标记中添加了属性appendTo ="@(body)".

I know this is a old question, but I was having the same problem with Primefaces 5. The solution was simple, I've included the attribute appendTo="@(body)" in tag.

<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>

这篇关于PrimeFaces对话框+​​ appendToBody = true不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆