Primefaces弹出对话框无效

时间:2013-03-05 08:00:54

标签: jsf-2 primefaces

我有一个带有弹出按钮的jsf页面,打开以下对话框弹出窗口:

</h:form>
<p:dialog id="dialog" header="Select different user"
        widgetVar="dlg" appendToBody="true">

    <h:form id="form23">
        <h:panelGrid columns="2" cellpadding="5">
            <h:outputLabel for="username" value="Username:" />
            <p:inputText value="#{loginBean.username}" 
                id="username" required="true" label="username" />

            <h:outputLabel for="password" value="Password:" />
            <h:inputSecret value="#{loginBean.password}" 
                id="password" required="true" label="password" />

            <f:facet name="footer">
                <p:commandButton id="loginButton" value="Login" />
            </f:facet>
        </h:panelGrid>
    </h:form>
</h:form>

但不是打开弹出窗口而是显示在页面外部。对话框在主窗体之外。帮助!


我试过了,但仍然存在同样的问题。现在是我修改过的代码..

<h:form id="create-ticket">
    <p:dialog id="dialog" header="Select different user" widgetVar="dlg" appendToBody="true">

    <h:panelGrid columns="2" cellpadding="5">
        <h:outputLabel for="username" value="Username:" />
        <p:inputText value="#{loginBean.username}" 
                id="username" required="true" label="username" />

        <h:outputLabel for="password" value="Password:" />
        <h:inputSecret value="#{loginBean.password}" 
                id="password" required="true" label="password" />

        <f:facet name="footer">
            <p:commandButton id="loginButton" value="Login" 
                />
        </f:facet>
    </h:panelGrid>

 </p:dialog>
     <h:panelGroup>
     <h:outputLabel value="#{I18N['Create_Ticket_for_other_users']}" styleClass="atf-header"></h:outputLabel>
    </h:panelGroup>
    <h:panelGroup id="search_section" layout="block"
       styleClass="atf-content-area atf-separarot-botton">   <!-- This is the section where we get the grey background -->
         <h:panelGroup id="input_search_section" styleClass="">
            <h:outputText id="name" value="Siddharth Mishra"    
            labelStyleClass="atf-label">
            </h:outputText>
        </h:panelGroup>
    <h:panelGroup styleClass="atf-right atf-inline-block">
        <p:commandButton id="btn_search" value="select different user"
            styleClass="atf-button-search" onclick="dlg.show();" type="button"
            >

        </p:commandButton>
    </h:panelGroup>

</h:panelGroup>

现在我只有一个表单你可以看到弹出对话框部分+在h:panelgroup.Atached下调用弹出窗口的按钮是图像当前表单的形式提前感谢enter image description here

1 个答案:

答案 0 :(得分:2)

您需要重新构建代码。

*不要将表单嵌套在其他表单中。

*你没有p:对话框的结束标记。

<h:form>    
    <p:dialog id="dialog" header="Select different user"
            widgetVar="dlg" appendToBody="true">

          //Content ex inputtext

    </p:dialog>

<p:commandButton value="Show Dialog" onclick="dlg.show();" type="button" />  
</h:form>