Saturday 12 November 2011

Usage of f:setPropertyActionListener

One of the frequent quest of JSF developers is to identify the calls to the same action method from different jsp's.The easiest way  is by binding the dynamic properties using setPropertyActionListener.This can be used inside any UIComponent subclass.The usage of the tags is like below,

<h:commandButton value="Button1" action="#{jsfbean.action}">
        <f:setPropertyActionListener target="#{jsfbean.propertyInBean}" value="propertyValue" />
</h:commandButton>

This actionListener on click of the commandButton will cause the value given by the "value" attribute to be set into the ValueExpression given by the "target" attribute.