For expressions, the framework uses OGNL (Object Graph Navigation Language)
- An expression (EL) and binding language for getting and setting properties of Java objects
- Normally the same expression is used for both getting and setting the value of a property
- Easy to learn, yet powerful
- Incrementally compiled expressions - fast !
- Embedded everywhere – views, ValueStack, *.xml
- Independent Open Source project - http: //www.ognl.org
||-- application||-- session||-- value stack(root)
context map ---|
|-- request||-- parameters||-- attributes (searches page in order : request > session > application)|
In expression, the properties of the root object can be referenced without any special "marker" notion.
<s:property value="postalCode"/>
References to other objects are marked with a pound sign (#).
<s:property value="#session.mySessionPropKey"/>
OGNL examples
user.name
getUser().getName()
user.toString()
getUser().toString()
item.categories[0]
First element of Categories collection
@com.example.Test@foo()
Calls the static foo() method of com.example.Test class.
name in {null, "fred"}
True: if name is null or "fred"
categories.{name}
Calls getName() on each category in the collection, returning a new collection (projection)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.