I can see that EL attributes are stored in the StateHelper
and String literals in the getAttributes()
map of a component. What is the lifecycle and why the need for two containers?
Also at what points in the lifecycle are EL ValueExpression
evaluated? (Every time the getStateHelper.eval()
is called?)
StateHelper
provides a convenience for component developers (who subclass UIComponent
directly and not a standard component) to maintain the state of a component across requests. It plays an integral role in JSF view state saving and the underlying contract provides more than just a means to stash component attributes.
By subclassing StateHelper
, a component developer can more conveniently key into the saveState
and restoreState
methods of StateHolder
, methods which are supposed to guarantee that a component (and child components) have their state correctly persisted (per the configured state saving mode) of the JSF Impl.
Contrast that with getAttributes()
map which is basically a stash of component variables, and is mostly relevant during the lifecycle of a single request. It offers no other services than to keep stuff.
ValueExpression
is evaluated at least 2x in a component's lifetime : RESTORE_VIEW
and UPDATE_MODEL_VALUES
phases, for obvious reasons: The first to give appropriate rendering of components and the second, to commit validated and converted values to the backing bean
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With