...
- To review basic concepts, refer to OGNL Basics
Webwork with OGNL
Webwork uses a standard naming context to evaluate OGNL expressions. The top level object dealing with OGNL is a map (usually referred as a context map). OGNL has a concept of a root object (in webwork terms, this is the OGNLValueStack). Along with the root, other objects are placed in the context map (referred as in the context) including your session/application/request/attr maps. These objects have nothing to do with the root, they just exist along side it in the context map. So, to access these objects, the # is used telling ognl not to look in the root object, but within the rest of the context
Code Block |
---|
|
|-- request
|
|--application
|
context map---|--OgnlValueStack(root)
|
|--session
|
|--attr
|
|--parameters
|
Note that their are other objects in the context map, I'm just referring to a few for this example. Now, your actions instances are placed in the OGNLValueStack so you can refer to your bean properties without the #.
Code Block |
---|
|
<ww: property value="myBean.myProperty"/>
|
For sessions,request, and the rest that lie in the context map:
Code Block |
---|
|
ActionContext.getContext().getSession().put("mySessionPropKey", mySessionObject);
|
Code Block |
---|
|
<ww: property value="#session.mySessionPropKey"/> or
<ww: property value="#session\['mySessionPropKey'\]"/>
<ww: property value="#attr.mySessionPropKey"/>
|
Collections (Maps, Lists, Sets)
...