Caching the result of an EL expression evaluation with in a life cycle
If you have the following code:
<h:h:outputText>#{someBean.user.firstName}></h:outputText>
<h:h:outputText>#{someBean.user.lastName}></h:outputText>
<h:h:outputText>#{someBean.user.age}"></h:outputText>
and if SomeBean.user() is a call to the db then every one of the above expressions will cause a trip to the db. Of course to get around this one simply has to cache the value of user from the db (the first time) and then return the cached value instead of going to the db again.
This is all well and good... however, I find myself writing a lot of this type of caching code in various places. It would seem that a much elegant solution would be to have the EL expression evaluator cache the result of an expression within a life cycle avoiding the need for every JSF developer to sprinkle caching code all over the place.
Then again there maybe something out there that does this already (magical config param?) I just could not find anything.
Thanks
-Sam