5

I am trying to skip the browser prompt to save the password for my login form.

I have already checked this question, and have added the autocomplete="off" attribute (on both form and fields).

Simply navigating to another page works fine. However when I use ?faces-redirect=true (in my Home button), I get the prompt.

admin.xhtml:

<h:form id="form" autocomplete="off">
    <p:growl id="growl" showDetail="true" sticky="false" life="3000" />  
    <p:layout fullPage="true">          
        <p:layoutUnit position="center" >
            <p:panel id="loginPanel" visible="#{not admin.loggedIn}">
                <h:panelGrid columns="2" cellpadding="5">
                    <f:facet name="header">
                        <h:outputLabel value="Administration" />
                    </f:facet>  

                    <h:outputLabel for="username" value="Username:" />
                    <p:inputText id="username" value="#{admin.username}" required="true" autocomplete="off" label="username" />

                    <h:outputLabel for="password" value="Password:" />
                    <p:password id="password" value="#{admin.password}" required="true" autocomplete="off" label="password" />

                    <f:facet name="footer">
                        <p:commandButton value="Login" update="growl loginPanel logoutPanel" 
                        process="loginPanel" actionListener="#{admin.login}" />
                    </f:facet>  
                </h:panelGrid>
            </p:panel>
        </p:layoutUnit>     
        <p:layoutUnit position="north" size="85">
            <p:panel id="logoutPanel">
                <p:commandButton value="Home" process="@this" 
                action="#{menuBean.goHome}" actionListener="#{admin.logout}" />
                <p:commandButton  rendered="#{admin.loggedIn}"
                value="Logout" update="loginPanel logoutPanel" 
                process="@this" actionListener="#{admin.logout}" />
            </p:panel>
        </p:layoutUnit>
    </p:layout>
</h:form>

MenuBean:

public String goHome() {
    String goToPage = "home.xhtml?faces-redirect=true";
    return goToPage;
}

Is there any way to deal with this?

Update I am using JSF 2.2.0 and Primaces 5.1. The issue appears on Chrome 42.0, I will test and update for other browsers.

Update 2 Seems to work correctly for IE 8.
I tried the passthrough attributes, (I can see the autocomplete=off in the generated source) but the behavior is the same.

 <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:a="http://xmlns.jcp.org/jsf/passthrough"
  xmlns:p="http://primefaces.org/ui">
    <h:form id="form" a:autocomplete="off">

Update 3 I tried disabling caching with the following ways:

Added meta tags to admin.xhtml:

 <h:head>  
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <title>Administration</title>   

Added the NoCacheFilter as indicated by this response. The HTTP headers are correctly updated:

Chrome Developer Tools

Still when I am redirected to home.xhtml in Chrome, I get the prompt.

Community
  • 1
  • 1
parakmiakos
  • 2,994
  • 9
  • 29
  • 43
  • Couple of questions: Does it fail in each browser? Does it fail with plain vanilla jsf inputs? What PF version are you using? – Kukeltje Apr 16 '15 at 15:43
  • Did not work for me as well using `` and `` or `` and `` (JSF 2.2.8-08/PrimeFaces 5.1, Google Chrome 41.0.2272.118 m, FireFox 37.0.1. This however, seem to have worked on Internet Explorer 8 - it may however, be an odd behaviour which I cannot reasonably trust. Besides, the attribute `autocomplete` itself is unavailable in ``). – Tiny Apr 16 '15 at 18:06
  • In the other question (which was in 2011) it says that the `autocomplete` tag would be available in the forms in JSF2.2, I assumed it was done. – parakmiakos Apr 17 '15 at 12:54
  • Try using passthrough, item 6 in this answer: http://stackoverflow.com/a/8494384/1341535 – Vsevolod Golovanov Apr 17 '15 at 12:58
  • To exclude one and other, do the values remain after you do a hard refresh (Ctrl+F5) on the redirected page? – BalusC Apr 17 '15 at 13:53
  • @BalusC When I hit refresh on the `admin.xhtml` page and then am redirected to `home.html`, I do not get the prompt. – parakmiakos Apr 19 '15 at 06:56
  • 1
    The comment reply is somewhat confusing, but I gather that you're actually seeing a browser-cached version of the page instead of getting a fresh one from the server. Try instructing the browser to not cache those pages. See also http://stackoverflow.com/questions/10305718/avoid-back-button-on-jsf-web-application/10305799#10305799 Let me know if that Q&A helps. – BalusC Apr 20 '15 at 05:51

0 Answers0