You can't trigger a change
event if the value has not changed. Indeed, one way is to supply a default value as in "Please select" with a #{null}
value or even with noSelectionOption="true"
in flavor of an additional <f:selectItem>
. This forces the enduser to actually change the value to a valid value.
E.g.
<p:selectOneMenu value="#{password.selectedPassword}" >
<f:selectItem itemValue="#{null}" itemLabel="--select--" />
<f:selectItems value="#{password.passwords}" var="val"
itemLabel="#{val}" itemValue="#{val}" />
<p:ajax update="psw1, psw2" listener="#{password.passwordChanged}"/>
</p:selectOneMenu>
Another way is to use <p:selectOneListbox>
instead, which is maybe better if you don't have many items.
<p:selectOneListbox value="#{password.selectedPassword}" >
<f:selectItems value="#{password.passwords}" var="val"
itemLabel="#{val}" itemValue="#{val}" />
<p:ajax update="psw1, psw2" listener="#{password.passwordChanged}"/>
</p:selectOneListbox>