I've noted a strange behaviour of the Primefaces 3.5 application that I'm currently writing. I was debugging my code code and it turned out that when I'm using a jsf component and try to pass a listener like this
<form:dictionarySelectInput id="country"
name="country"
label="label.claim.BelongingsSecondPage.property.country"
filter="true"
value="#{belongingsDataGatheringBean.page.belongingsSection.propertyBelonging.country}"
items="#{belongingsDataGatheringBean.dictionaries.countryDictionary()}"
listener="#{belongingsDataGatheringBean.changeCountryListener()}"
update="@([id$=state\\:state-panel])"/>
then during rendering the view the method is called by itself. Here's how the component uses the listener:
<p:selectOneMenu id="#{cc.attrs.name}-input" value="#{cc.attrs.value}" styleClass="select #{cc.attrs.styleClass}" filter="#{cc.attrs.filter}" converter="omnifaces.SelectItemsConverter">
<f:selectItem itemLabel="#{msg['common.select.empty']}" noSelectionOption="true"/>
<f:selectItems value="#{cc.attrs.items}" var="item" itemLabel="#{item.value}" itemValue="#{item}"/>
<c:choose>
<c:when test="${empty cc.attrs.listener}">
<p:ajax disabled="#{empty cc.attrs.update}" process="@this" listener="#{cc.attrs.listener}" update="#{cc.attrs.update}"/>
</c:when>
<c:otherwise>
<p:ajax disabled="#{empty cc.attrs.update}" process="@this" update="#{cc.attrs.update}"/>
</c:otherwise>
</c:choose>
</p:selectOneMenu>
How to prevent the listener from firing itself?