A usual requirement when building a JSF or Oracle ADF form is to set binding values not added by the user automatically on a button click. For example, setting a technical ID in an Entity Object right before executing a commit on the table.
To do so, you can use a core JSF functionality with the f:setPropertyActionListener tag:
Register an ActionListener instance on the UIComponent associated with the closest parent UIComponent custom action. This actionListener will cause the value given by the “value” attribute to be set into the ValueExpression given by the “target” attribute.
The implementation of this tag creates a special ActionListener
instance and registers it on the ActionSource
associated with our most immediate surrounding instance of a tag whose implementation class is a subclass of UIComponentTag
. This tag creates no output to the page currently being created.
The ActionListener
instance created and installed by this tag has the following behavior and contract.
- Only create and register the
ActionListener
instance the first time the component for this tag is created - The “target” and “value” tag attributes are ValueExpression instances and are stored unevaluated as instance variables of the listener.
- When the listener executes, perform the following:
Call getValue() on the “value” ValueExpression.If value of the “value” expression is null, call setValue() on the “target” ValueExpression with the null value.If the value of the “value” expression is not null, call getType() on the “value” and “target” ValueExpressions to determine their property types.Coerce the value of the “value” expression to the “target” expression value type following the Expression Language coercion rules. Call setValue() on the “target” ValueExpression with the resulting value.If either coercion or the execution of setValue() fails throw an AbortProcessingException.