Book Image

PrimeFaces Cookbook

Book Image

PrimeFaces Cookbook

Overview of this book

Table of Contents (20 chapters)
PrimeFaces Cookbook Second Edition
Credits
Foreword
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Enhanced password input


The password component is an extended version of the JSF <h:inputSecret> component, which also provides a strength indicator and the match mode.

How to do it…

The basic declaration for the component will provide no feedback on the input password and will just render a simple input component:

<p:password value="#{passwordBean.password}" />

To enable the strength indicator, the feedback attribute should be set to true. By default, the indicator will be rendered right next to the component when it is hovered:

When feedback is enabled, it's also possible to set the prompt label and the strength label with the promptLabel, weakLabel, goodLabel, and strongLabel attributes. This will help to localize the password input component according to the need:

<p:password value="#{passwordBean.password}" feedback="true"
  promptLabel="#{msg['password.promptLabel']}"
  weakLabel="#{msg['password.weakLabel']}"
  goodLabel="#{msg['password.goodLabel']}"
  strongLabel="#{msg...