< p:dialog appendToBody ="true";不调用Converter类 [英] <p:dialog appendToBody="true" doesn't call Converter class

查看:1121
本文介绍了< p:dialog appendToBody ="true";不调用Converter类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Primefaces 3.4.2与JSF 2.0一起使用

I am using Primefaces 3.4.2 with JSF 2.0

在JSF页面的对话框弹出窗口中,有以下内容.

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>

如果我使用appendToBody="true",则不会调用selectOneMenu Converter类,但是如果我将其创建为appendToBody="false",则将调用Converter类.

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.

这可能是什么原因? appendToBody="false"使我的弹出对话框不可用,无法使用鼠标进行导航.

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

如何解决此问题?

推荐答案

删除appendToBody并将<h:form/>放入对话框中(及其内容).

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

appendToBody="false"的目的是确保对话框在HTML输出的主体内(因此也在主<h:form/>内部)呈现.

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.

如果没有appendToBody="false",则该对话框可能最终会附加到<body/>中标记的末尾,结果,其中的任何内容都不会执行.

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.

在对话框中添加<h:form/>可以确保即使它在<body/>之外结束,它仍然可以提交给服务器

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

这篇关于&lt; p:dialog appendToBody ="true";不调用Converter类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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