I am still unclear about the use of JSF immediate evaluation
vs deferred evaluation
, mainly because the online examples almost never seem to use the former method.
I have seen a fair amount of JSF Examples, including those contained in http://docs.oracle.com/javaee/6/tutorial/doc/, and I am a bit puzzled by the fact that I almost only ever see examples with #{}
instead of ${}
, even when all we're doing is reading a bean property.
From my understanding of these two uses, ${}
can only be used to read bean properties, not to write. I have yet to find a clear explanation of the exact difference of immediate
vs deferred
evaluation in respect to the JSF life cycle and what difference that would make for reading bean properties.
If everyone always uses the #{}
for reading bean properties, when would you recommend the use of ${}
?
So, in summary:
#{}
over ${}
when reading bean properties?${}
instead of #{}
?${}
would have a different result from using #{}
(and can you explain why the result is different)?A formal measurement of student learning that may include, but is not. limited to, an examination, a test, an assignment or a project. Exceptional. circumstances. Serious illness, personal or family tragedy, religious observance, legal.
Immediate evaluation means that the expression is evaluated and the result returned as soon as the page is first rendered.
Immediate and Deferred Evaluation Syntax. The unified EL supports both immediate and deferred evaluation of expressions.
In Facelets, the ${}
is treated as #{}
, so there's technically no difference and it's always deferred.
In JSP 2.0 and older, the ${}
won't autocreate the managed bean when it's not in scope yet. You can thus only use it if you can guarantee that #{}
on the very same managed bean is been used somewhere before in the component tree and also take view build time vs view render time lifecycle into account. In all JSP versions, the ${}
can't set submitted values of JSF input components in model. All in all, mixing them is potentially confusing to starters and in long term even also to yourself and therefore not recommended.
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