Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
406 views
in Technique[技术] by (71.8m points)

jsf - <p:dialog appendToBody="true" doesn't call Converter class

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...