Password component is an extended version of standard inputSecret component with theme integration, strength indicator and match mode.
<div class="card">
<h:form>
<h5><p:outputLabel for="@next" value="Basic"/></h5>
<p:password id="nonFeedback" value="#{passwordView.password1}"/>
<h5><p:outputLabel for="@next" value="Feedback"/></h5>
<p:password id="feedback" value="#{passwordView.password2}" feedback="true"/>
<h5><p:outputLabel for="@next" value="Feedback - Spanish"/></h5>
<p:password id="turkishFeedback" value="#{passwordView.password3}" feedback="true"
promptLabel="Ingresa tu contraseña" weakLabel="Débil"
goodLabel="Buena" strongLabel="Fuerte"/>
<h5><p:outputLabel for="@next" value="Inline Feedback"/></h5>
<p:password id="inlineFeedback" value="#{passwordView.password5}" feedback="true" inline="true"/>
<h5><p:outputLabel for="@next" value="Toggle Mask"/></h5>
<p:password id="toggle" value="#{passwordView.password6}" toggleMask="true" redisplay="true"/>
</h:form>
</div>
<div class="card">
<h:form>
<h5 class="mt-0">Match Passwords</h5>
<div class="field grid">
<p:outputLabel for="pwd1" styleClass="col-fixed" style="width:100px" value="Password"/>
<div class="col">
<p:password id="pwd1" value="#{passwordView.password5}" match="pwd2" label="Password 1" required="true"/>
</div>
</div>
<div class="field grid">
<p:outputLabel for="pwd2" styleClass="col-fixed" style="width:100px" value="Password"/>
<div class="col">
<p:password id="pwd2" value="#{passwordView.password5}" label="Password 2" required="true"/>
</div>
</div>
<p:commandButton update="@form" value="Save"/>
<p:messages id="messages" showDetail="true">
<p:autoUpdate/>
</p:messages>
</h:form>
</div>
@Named
@RequestScoped
public class PasswordView implements Serializable {
private String password1;
private String password2;
private String password3;
private String password4;
private String password5;
private String password6 = "OpenSesame";
public String getPassword1() {
return password1;
}
public void setPassword1(String password1) {
this.password1 = password1;
}
public String getPassword2() {
return password2;
}
public void setPassword2(String password2) {
this.password2 = password2;
}
public String getPassword3() {
return password3;
}
public void setPassword3(String password3) {
this.password3 = password3;
}
public String getPassword4() {
return password4;
}
public void setPassword4(String password4) {
this.password4 = password4;
}
public String getPassword5() {
return password5;
}
public void setPassword5(String password5) {
this.password5 = password5;
}
public String getPassword6() {
return password6;
}
public void setPassword6(String password6) {
this.password6 = password6;
}
}