<p:dialog appendToBody=“true” doesn't call Converter class

為{幸葍}努か 提交于 2019-12-12 03:45:46

问题


I am using Primefaces 3.4.2 with JSF 2.0

I have the following in a dialog popup in JSF page.

<p:dialog header="Create New Request" style="font-weight:bold"
        widgetVar="newDialog" resizable="false" id="newDlg"
        showEffect="fade" hideEffect="fade" appendToBody="true"
        modal="true" position="center top" width="850" height="450">
        <p:panelGrid columns="2">
        <h:outputLabel value="Employee" for="employee" />
            <p:selectOneMenu id="employee" value="#{mymb.employee}" 
            converter="#{employeeConverter}">
         <f:selectItems value="#{mymb.employeeItems}" var="emp"
        itemLabel="#{emp.employeeName}" itemValue="#{emp.employeeNumber}"/>
       <p:ajax listener="#{mymb.loadDepartments}"  process="@this"/>
</p:selectOneMenu>

        </p:panelGrid>
        <p:separator />
            </p:dialog>

If I use appendToBody="true", then selectOneMenu Converter class doesn't gets invoked, but if I make it appendToBody="false", then Converter class gets invoked.

What could be the reason for this? appendToBody="false" makes my popup dialog unusable, not able to navigate using mouse.

How can I resolve this issue?


回答1:


Remove the appendToBody and put an <h:form/> inside your dialog(along with it's content).

The purpose of appendToBody="false" is to ensure your dialog is rendered within the body (and hence within the main <h:form/>) of the HTML output.

Without appendToBody="false" , the dialog might end up being appended to the end of the markup in <body/> and as a result, nothing inside it will get executed.

Adding <h:form/> to your dialog ensures that even if it winds up outside the <body/> it will still be able to submit to the server



来源:https://stackoverflow.com/questions/15033101/pdialog-appendtobody-true-doesnt-call-converter-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!