4

Let we have some facelet 1.xhtml that contains

<h:inputText id="prop" value="#{MyBean.myProperty}"/>

and facelet 2.xhtml that contains

<h:inputText id="prop" value="${MyBean.myProperty}"/>

Quote from official tutorial:

Immediate evaluation means that the expression is evaluated and the result returned as soon as the page is first rendered. 

I dont understand at what specific phase immediate expression is evaluate? At Render Response phase or Update model values or Apply request or what?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

6

The tutorial is talking about legacy JSP. When using JSF on JSP, the ${} is always evaluated during view build time, regardless of where it's declared. It's like as how JSTL, taghandlers and id/binding attributes work in JSF. See also JSTL in JSF2 Facelets... makes sense? for some in depth explanation.

In JSP's successor Facelets, however, the ${} is treated exactly the same way as #{}. So ${} evaluation is also deferred. To avoid confusion among yourself and the future maintainers of your Facelets code, it's strongly recommended to abandon usage of ${} in Facelets and stick to #{} all the time.

The deferred expression is evaluated every time when its result is needed during runtime. In case of UIInput components, that's one time during validations phase (to check if the submitted value has changed as compared to (old!) model value, before triggering all value change listeners) and one time during render response (to generate HTML output with (new!) model value). If it were evaluated immediately, setting and obtaining the new model value wouldn't have worked.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555