Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

jsf - Disable web browser password save

I have a simple Login page made with JSF 2.0. Usually in every login page the web browser proposes to the user to save his username a password.

I saw in Oracle's web site where user must authenticate that when I enter my username and password the browser do not ask me do I want to save my username and password. Maybe there is a way to disable this from the code of the login page.

Is this possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You basically need to add autocomplete="off" attribute to the HTML <form> element. However, this attribute is not supported on the <h:form>. It's only supported on the individual <h:inputText> and <h:inputSecret> components.

So, this should do:

<h:form>
    <h:inputText value="#{auth.username}" required="true" autocomplete="off" />
    <h:inputSecret value="#{auth.password}" required="true" autocomplete="off" />
    <h:commandButton value="Login" action="#{auth.login}" />
    <h:messages />
</h:form>

The new autocomplete attribute on <h:form> is scheduled for JSF 2.2. See also JSF spec issue 418.

Or, if you're using container managed login with j_security_check which requires a plain vanilla HTML <form> anyway, then just add it in there:

<form action="j_security_check" method="post" autocomplete="off">
    <input type="text" name="j_username" />
    <input type="password" name="j_password" />
    <input type="submit" value="Login" />
</form>

See also:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...