[jboss-user] [JBoss Seam] - Re: evaluting s:hasPermission once only in a page

gavin.king@jboss.com do-not-reply at jboss.com
Tue May 29 17:10:29 EDT 2007


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}.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049543#4049543

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049543



More information about the jboss-user mailing list