What is the role and life cycle of StateHelper?

I see that the EL attributes are stored in the StateHelper and String literals on the getAttributes() map of the component. What is the life cycle and why are two containers needed?

Also, at what points in the life cycle are EL ValueExpression ? (Each time getStateHelper.eval() is getStateHelper.eval() ?)

+4
source share
1 answer
  • StateHelper provides convenience for component developers (who subclass UIComponent directly rather than a standard component) to maintain the state of the component through queries. It plays an integral role in maintaining the state of a JSF view, and a basic contract provides more than just a means of storing component attributes.

    When subclassing StateHelper , the component developer can more conveniently use the saveState and restoreState StateHolder methods, methods that should ensure that the component (and its child components) are saved correctly (in accordance with the configured state saving mode) of JSF Impl.

    Contrast this with a getAttributes() map, which is basically a list of component variables and mostly relevant throughout the life cycle of a single request. He does not offer any other services except to store things.

  • ValueExpression is evaluated at least 2x in the component's lifetime: RESTORE_VIEW and UPDATE_MODEL_VALUES for obvious reasons: the first is for the corresponding rendering of components, and the second is for fixing confirmed and converted values ​​to a backup bean

+6
source

Source: https://habr.com/ru/post/1480223/


All Articles