0

I am doing a project using primefaces.

In that I am using user login page.

My problem is that, when I click on the password textbox (p:inputText) the suggestions for previously saved password value is appeared on the p:inputText.

I have tried autocomplete=“off” in p:inputText and I cleared my Chrome browser history on every login but still its not working well. Before I was using autocomplete="new-password" it was working fine and was not showing suggestions. But Now Chrome Version is updated to 58.0.3029.96 So, in latest version of chrome it is not working.

Any idea?

2 Answers2

1

You should use p:password for password input, not p:inputText. p:password renders HTML input type="password", which makes a browser treat it properly in regards to safety. A browser will never autocomplete a password into a non-password field. But if you use a basic inputText then a browser doesn't know that it's a password.

Vsevolod Golovanov
  • 3,355
  • 3
  • 25
  • 59
  • 1
    But it's not showing the password in plain text, that's the important part. If you want to prevent password suggestions at all, then that's going to be hard. There is no way to do this reliably, all browsers ignore attemps to disable autosave currently. PrimeFaces won't help you here, you'll need to do some trickery with plain HTML/JS. E.g. see the many answers to http://stackoverflow.com/q/2530/1341535 – Vsevolod Golovanov May 12 '17 at 11:01
  • A couple of useful articles: https://dolske.wordpress.com/2013/08/ - how Firefox's Password Manager works. I think it's a bit outdated, but it should give you an idea of what you're up against. – Vsevolod Golovanov May 12 '17 at 11:05
0

I faced the same problem with Safari and p:autoComplete PrimeFaces 5.0. My solution was to prefix value with a space (not empty, not blank) on focus and then trim the space on blur:

<p:autoComplete value="#{inputBean.operator}"... onfocus="this.value = ' ' + this.value;" onblur="this.value = this.value.trim();" onchange="this.value = this.value.trim();"/>

It worked for me. The space is hardly noticeable for user. Only problem is onblur() is not fired sometimes, I don't know why, so I include onchange() to be sure to trimming the value.

I tried to use this technic with p:password:

<p:password value="#{loginBean.password}" ... onfocus="this.value = ' ' + this.value;" onblur="this.value = this.value.trim();"

Though it works, it may startle user to find a dot (•) even before she/he starts writing, but it really prevents browser from autocomplete. Normal user reaction is to delete that dot and type her/his password; if dot is not deleted by user, onblur() does.

onClick
  • 29
  • 3
  • Your answer is about the `p:autoComplete` component while the question and existing answer are about autocomplete in a `p:password` field, so your answer is not related to the question. – Kukeltje Oct 26 '17 at 07:44
  • Then why not change the answer and put a `p:password` in there? – Kukeltje Oct 27 '17 at 15:23
  • Thanks @onClick.... But when we delete that space i.e dot (•), again it will show suggestions of all stored password(usernames) and user can still select the username. Once he select the username then password also appear in input field. – Harshal_Kalavadiya Nov 06 '17 at 10:24