Search code examples
jsfjsf-2.2jsf-stateless

JSTL and bindings in the stateless mode


An excerpt taken from a book,

For a stateless view, the component tree cannot be dynamically generated/changed (for example, JSTL and bindings are not available in the stateless mode). You can't create/manipulate views dynamically.

I perfectly understand the concept of going stateless as in a login form.

What I don't understand is the author's point on, JSTL and bindings are not available in the stateless mode. Please elucidate.


Solution

  • The author seems to be confused itself or overgeneralizing a bit too much.

    The component tree can certainly still be dynamically generated/changed. This does not depend on stateful/stateless mode. The only difference with stateful mode is that those dynamic actions won't be remembered in JSF state, so they can't be restored in the postback.

    It will in stateless mode continue to work fine if those dynamic changes are initiated by a non-user event during view build time, such as @PostConstruct of a request scoped bean referenced via binding attribute, or a postAddToView event listener method. It will simply be re-executed. If the method logic however in turn depends on some user-controlled variables/actions, such as request parameters or actions invoked during previous postbacks, or it is executed too late, such as during the preRenderView event, then it's not anymore guaranteed that the view will during apply request values phase of the subsequent postback become identical as it was during rendering the form to be submitted. In such case, processing the form submit may behave "unexpectedly" different as compared to a stateful view.