f:setPropertyActionListener doesn't set the value however action is triggered

jsf, primefaces

Solution

The `<f:setPropertyActionListener>` works as being an `ActionListener` implementation only on components implementing `ActionSource` interface, such as `UICommand`, i.e. `<h:commandXxx>`, `<p:commandXxx>`, etc. The `<p:ajax>` does not implement this interface and therefore the `<f:setPropertyActionListener>` is basically completely ignored.

As to your workaround, you could do so although I'd rather just use a concrete view scoped bean or wrap it in a composite with a backing component.

Problem

I need to set a boolean field whenever `p:fieldset` is toggled. I tried out following code but the field is never set by f:setPropertyActionListener although p:ajax listener is invoked on toggle. I tried out following code. ``` <p:fieldset legend="(Optional) Link.." toggleable="true"> <p:ajax event="toggle" listener=".."> <f:setPropertyActionListener target="#{viewScope.rendrUsrProjctsList}" value="#{true}"/> </p:ajax> </p:fieldset> ``` However when I tried modifying the code as below then field is successfully set: ``` <p:fieldset legend="(Optional) Link.." toggleable="true"> <p:ajax event="toggle" listener="#{view.viewMap.put('rendrUsrProjctsList', true)}" /> <p:ajax event="toggle" listener=".."/> </p:ajax> </p:fieldset> ``` I want to ask: - Why 1st way doesn't work ? - Is it bad attaching multiple `p:ajax` to single parent as done in 2nd way ?

Original source

Related problems