パスワード確認コンポーネントがあります。ユーザーは、2つのパスワードを手動で入力することも、ペアを生成することもできます。生成されたパスワードは選択リストに表示されます。リストからパスワードを選択した場合、2つの入力パスワードをこのパスワードで更新する必要があります。問題は、パスワードが選択された後の変更が入力パスワードに反映されないことです。
パスワード確認コンポーネント:
<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リスナー:
public void passwordChanged() {
this.password = selectedPassword;
this.confirmedPassword = selectedPassword;
}
編集1
からupdate属性を削除し、リスナーを次のようp:ajax
に変更しました。passwordChanged
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");
}
Firebugでは、psw1のIDは次のとおりですform:tabs:9:editorsGroup:4:editor27:psw1
。それでも動作しません。