I have a password confirmation component. The user can enter the two passwords manually or can generate a pair. The generated passwords are shown in a select list. When a password is selected from the list, the two input passwords should be updated with this password. The problem is that the input password doesn't reflect the change after a password was selected.
password confirmation component:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:outputText value="#{eval.getString(name)}: #{mandatory ? '*' : ''}"/>
<h:panelGrid columns="3">
<h:column>
<p:password id="psw1"
value="#{eval.evaluateAsBean(beanName).password}" feedback="false"
disabled="#{not enabled}" />
</h:column>
<h:column>
<p:commandButton value="#{label.create}" disabled="#{not enabled}"
action="#{eval.evaluateAsBean(beanName).generate}"
update="generated">
</p:commandButton>
</h:column>
<h:column>
<p:selectOneMenu id="generated"
disabled="#{not enabled}"
value="#{eval.evaluateAsBean(beanName).selectedPassword}">
<f:selectItems value="#{eval.evaluateAsBean(beanName).passwords}"
var="val" itemLabel="#{val}" itemValue="#{val}" />
<p:ajax listener="#{eval.evaluateAsBean(beanName).passwordChanged}"
update="psw1, psw2" />
</p:selectOneMenu>
</h:column>
<h:column>
<p:password id="psw2"
value="#{eval.evaluateAsBean(beanName).confirmedPassword}"
feedback="false" disabled="#{not enabled}" />
</h:column>
<h:column>
<h:outputText value="" />
</h:column>
<h:column>
<h:outputText value="" />
</h:column>
</h:panelGrid>
</ui:composition>
passwordChanged listener:
public void passwordChanged() {
this.password = selectedPassword;
this.confirmedPassword = selectedPassword;
}
Edit1
I have removed the update attribute from p:ajax
and changed passwordChanged
listener to:
public void passwordChanged() {
this.password = selectedPassword;
this.confirmedPassword = selectedPassword;
RequestContext.getCurrentInstance().update("form:tabs:editorsGroup:editor:psw1");
RequestContext.getCurrentInstance().update("form:tabs:editorsGroup:editor:psw2");
}
With Firebug the id of psw1 is: form:tabs:9:editorsGroup:4:editor27:psw1
. Still doesn't work.