页面刷新后,primefaces对话框保持呈现

时间:2016-02-29 09:45:44

标签: jsf jsf-2 primefaces dialog

我正在使用PrimeFaces实现登录页面。

开发重置密码对话框时遇到奇怪的行为。

这是我的login.xhtml

<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <f:metadata>
        <f:event type="preRenderView" listener="#{loginManager.onPrerenderView}"/>
    </f:metadata>

    <h:head>
        <h:outputStylesheet name="css/admin.css"></h:outputStylesheet>
    </h:head>

    <h:body>
        <h:form id="loginForm" binding="#{loginManager.loginForm}">
            <div class="login">
                <div class="login-screen">
                    <p:message for="loginForm" id="message"/>
                    <div class="login-form">
                        <div class="control-group">
                            <h:inputText class="login-field" id="login-name" placeholder="username" required="true" rendered="true" value="#{loginManager.username}"/>
                            <label class="login-field-icon fui-user" for="login-name"></label>
                        </div>
                        <div class="control-group">
                            <h:inputSecret class="login-field" id="login-pass" placeholder="password" required="true" value="#{loginManager.password}" />
                            <label class="login-field-icon fui-lock" for="login-pass"></label>
                        </div>
                        <p:commandButton value="Login" action="#{loginManager.login}" update="message" styleClass="btn btn-primary btn-large btn-block" />
                        <br/>
                            <h:outputLink id="openDialogLink" value="javascript:void(0)" onclick="PF('dlg').show();" style="color: white;">Lost your password?</h:outputLink>
                            <p:dialog id="lostPwd" widgetVar="dlg" header="Reset Password" visible="false" closeOnEscape="true" resizable="false" showEffect="clip" hideEffect="clip">
                                <h:panelGrid columns="2" cellpadding="5">
                                    <h:outputLabel for="username" value="Username:" />
                                    <h:inputText placeholder="username" required="true" value="#{loginManager.usernameForReset}"/>
                                    <f:facet name="footer" >
                                        <p:commandButton  value="Reset" actionListener="#{loginManager.resetPwd}" update="@form" oncomplete="PF('dlg').hide();" />
                                    </f:facet>  
                                </h:panelGrid>
                            </p:dialog>
                        <p class="browser-warn">Best used with Chrome / Firefox</p>
                    </div>
                </div>
                <div style="clear: both"></div>
            </div>
        </h:form>
    </h:body>

</html>

我第一次加载页面时看起来很正常:

everything is ok

但是在刷新页面之后:

stays on the page

请澄清为何发生这种情况。这有什么不对?也许有些配置问题?

0 个答案:

没有答案