【问题标题】:Primefaces popup dialog not workingPrimefaces弹出对话框不起作用
【发布时间】:2013-02-19 13:06:01
【问题描述】:

我有一个 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 下调用弹出窗口的按钮。附件是表单当前的外观提前感谢

【问题讨论】:

  • 如果您需要帮助重构您的代码明确了解您的问题是什么、到目前为止您已经尝试过什么以及您会做什么喜欢达到。删除您的“答案”并改为编辑您的问题。

标签: jsf-2 primefaces


【解决方案1】:

你需要重构你的代码。

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

*你没有 p:dialog 的结束标签。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-10
    • 1970-01-01
    • 2014-12-24
    • 2014-11-18
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 2013-07-02
    相关资源
    最近更新 更多