On Fri, 15 Jun 2007 09:49:42 -0500
noah <iamnoah_at_gmail.com> wrote:
> On 6/14/07, Todd Patrick <Todd.Patrick_at_dtn.com> wrote:
> >
> >
> > I have a feeling that I've inflicted my current misery due to my
> > lack of knowledge about ValueExpressions and LifeCycle Phases.
> >
> > At which LifeCycle Phase are ValueExpressions in Java code (managed
> > bean) rendered?
>
> ValueExpresions can be evaluated at any phase. e.g. an expression for
> the rendered attribute will be evaluated at every phase because it
> determines whether or not the component processes in that phase.
>
> If you have an expression that is expensive to evaluate, you need to
> cache the result.
In Gravel, there is a <ga:attribute> tag that caches the value of an
attribute and preserves it even between requests. You can replace this:
<h:outputText value="Blah" rendered="#{some.expression}"/>
with:
<h:outputText value="Blah">
<ga:attribute name="rendered" value="#{some.expression}"/>
</h:outputText>
and the value will stay cached on the view state and will not be
reevaluated until the subsequent RENDER_RESPONSE phase, if there is a
postback.
This is also useful if you are using the result of an expression that
expires after the request completes. Using this tag, the expression
value is still visible during the subsequent postback.
- DML