0

I am implementing a login page using PrimeFaces.

Faced with a strange behaviour when developing a Reset Password Dialog.

Here is my 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>

The first time I load the page, it looks normal:

everything is ok

But after I refresh the page:

stays on the page

Please clarify why this happening. What is wrong here ? Maybe some config issue?

  • Why do you have `actionListener` instead of `action` in reset button `p:commandButton`? http://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener – Geinmachi Feb 29 '16 at 12:23
  • You are right, I should use action instead. But again the problem still exists – Khayyam Sadigov Feb 29 '16 at 14:35

0 Answers0