public class WebappUberspector
extends org.apache.velocity.util.introspection.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
Modifier and Type | Class and Description |
---|---|
class |
WebappUberspector.GetAttributeExecutor
Executor for getAttribute(name) method.
|
class |
WebappUberspector.SetAttributeExecutor
Executor for setAttribute(name,value) method
|
org.apache.velocity.util.introspection.UberspectImpl.VelGetterImpl, org.apache.velocity.util.introspection.UberspectImpl.VelMethodImpl, org.apache.velocity.util.introspection.UberspectImpl.VelSetterImpl
Constructor and Description |
---|
WebappUberspector() |
Modifier and Type | Method and Description |
---|---|
org.apache.velocity.util.introspection.VelPropertyGet |
getPropertyGet(Object obj,
String identifier,
org.apache.velocity.util.introspection.Info i)
Property getter
|
org.apache.velocity.util.introspection.VelPropertySet |
getPropertySet(Object obj,
String identifier,
Object arg,
org.apache.velocity.util.introspection.Info i)
Property setter
|
void |
init()
init method
|
getIterator, getMethod, wrap
public org.apache.velocity.util.introspection.VelPropertyGet getPropertyGet(Object obj, String identifier, org.apache.velocity.util.introspection.Info i)
getPropertyGet
in interface org.apache.velocity.util.introspection.Uberspect
getPropertyGet
in class org.apache.velocity.util.introspection.AbstractChainableUberspector
obj
- target objectidentifier
- property keyi
- tool infopublic void init()
init
in interface org.apache.velocity.util.introspection.Uberspect
init
in class org.apache.velocity.util.introspection.AbstractChainableUberspector
public org.apache.velocity.util.introspection.VelPropertySet getPropertySet(Object obj, String identifier, Object arg, org.apache.velocity.util.introspection.Info i)
getPropertySet
in interface org.apache.velocity.util.introspection.Uberspect
getPropertySet
in class org.apache.velocity.util.introspection.AbstractChainableUberspector
obj
- target objectidentifier
- property keyarg
- value to seti
- tool infoCopyright © 2002–2021 The Apache Software Foundation. All rights reserved.