This content has been marked as final.
Show 3 replies
-
1. Re: evaluting s:hasPermission once only in a page
gavin.king May 29, 2007 5:10 PM (in response to ptalekar)I guess this is generally useful:
@Name("cachedValue") @Install(false) public class CachedValue { private ValueBinding value; //Use ValueExpression in Seam 1.3 private Object cachedValue; public void setValue(ValueBinding value) { this.value = value; } public ValueBinding getValue() { return value; } @Unwrap public Object get() { if (cachedValue==null) { cachedValue = getValue().getValue(); } return cachedValue; } }
Declare a cached value like this:<component name="hasPermission" class="CachedValue" scope="session"> <property name="value">#{s:hasPermission('enterprise', 'edit', null)}</property> </component>
(You can similarly declare any other cached values, and their scopes.)
And use it like #{hasPermission}. -
2. Re: evaluting s:hasPermission once only in a page
gavin.king May 29, 2007 5:11 PM (in response to ptalekar)Note that the class ValueBinding is a org.jboss.seam.core.Expressions.ValueBinding, not the JSF class.
-
3. Re: evaluting s:hasPermission once only in a page
gavin.king May 29, 2007 5:13 PM (in response to ptalekar)Of course, it would be easy to simplify the config to:
<n:cachedValue scope="session" value="#{s:hasPermission('enterprise', 'edit', null)}"/>
just by using @Namespace.