org.apache.velocity.tools.view
Class WebappUberspector

java.lang.Object
  extended by org.apache.velocity.util.introspection.UberspectImpl
      extended by org.apache.velocity.util.introspection.AbstractChainableUberspector
          extended by org.apache.velocity.tools.view.WebappUberspector
All Implemented Interfaces:
ChainableUberspector, Uberspect, UberspectLoggable

public class WebappUberspector
extends AbstractChainableUberspector

This custom uberspector allows getAttribute() and setAttribute() as standard getters and setters for the "request","session" and "application" keys.

It allows VTL statements like:

 #set($session.foo = 'youpi')
 session parameter 'foo' has value: $session.foo
 

This uberspector requires Velocity 1.6+ ; to use it, you must specify org.apache.velocity.tools.view.WebappUberspector as the last uberspector to the runtime.introspector.uberspect property in you velocity.properties file.

For instance:

runtime.introspector.uberspect = org.apache.velocity.util.introspection.UberspectImpl,org.apache.velocity.tools.view.WebappUberspector

Version:
$Id: WebappUberspector.java $
Author:
Claude Brisson

Nested Class Summary
 class WebappUberspector.GetAttributeExecutor
          Executor for getAttribute(name) method.
 class WebappUberspector.SetAttributeExecutor
          Executor for setAttribute(name,value) method
 
Nested classes/interfaces inherited from class org.apache.velocity.util.introspection.UberspectImpl
UberspectImpl.VelGetterImpl, UberspectImpl.VelMethodImpl, UberspectImpl.VelSetterImpl
 
Field Summary
 
Fields inherited from class org.apache.velocity.util.introspection.AbstractChainableUberspector
inner
 
Fields inherited from class org.apache.velocity.util.introspection.UberspectImpl
introspector, log
 
Constructor Summary
WebappUberspector()
           
 
Method Summary
 VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
          Property getter
 VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info i)
          Property setter
 void init()
          init method
 
Methods inherited from class org.apache.velocity.util.introspection.AbstractChainableUberspector
getIterator, getMethod, wrap
 
Methods inherited from class org.apache.velocity.util.introspection.UberspectImpl
setLog, setRuntimeLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebappUberspector

public WebappUberspector()
Method Detail

getPropertyGet

public VelPropertyGet getPropertyGet(Object obj,
                                     String identifier,
                                     Info i)
                              throws Exception
Property getter

Specified by:
getPropertyGet in interface Uberspect
Overrides:
getPropertyGet in class AbstractChainableUberspector
Parameters:
obj -
identifier -
i -
Returns:
A Velocity Getter Method.
Throws:
Exception

init

public void init()
init method

Specified by:
init in interface Uberspect
Overrides:
init in class AbstractChainableUberspector

getPropertySet

public VelPropertySet getPropertySet(Object obj,
                                     String identifier,
                                     Object arg,
                                     Info i)
                              throws Exception
Property setter

Specified by:
getPropertySet in interface Uberspect
Overrides:
getPropertySet in class AbstractChainableUberspector
Parameters:
obj -
identifier -
arg -
i -
Returns:
A Velocity Setter method.
Throws:
Exception


Copyright © 2002-2013 Apache Software Foundation. All Rights Reserved.