Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Code Block
[0].name   // call to animal.getName()
[1].name   // call to person.getName()

Wiki MarkupWith expression like \ [0\] ... \ [3\] etc. Struts 2 will cut the stack and still return back a CompoundRoot object. To get the top of that particular stack cut, use [0].top

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2445a48e-ce04-441a-9eca-5152526b3ab5"><ac:plain-text-body><![CDATA[

ognl expression

description

[0].top

would get the top of the stack cut starting from element 0 in the stack (similar to top in this case)

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3eb84697-77c0-40bf-9241-5bf11128d436"><ac:plain-text-body><![CDATA[

[1].top

would get the top of the stack cut starting from element 1 in the stack]]></ac:plain-text-body></ac:structured-macro>

Accessing static properties

...

Differences from the WebWork 1.x EL

Wiki MarkupBesides the examples and descriptions given above, there are a few major changes in the EL since WebWork 1.x. The biggest one is that properties are no longer accessed with a forward slash \ (/\) but with a dot (.). Also, rather than using ".." to traverse down the stack, we now use "\[n\]" where n is some positive number. Lastly, in WebWork 1.x one could access special named objects (the request scope attributes to be exact) by using "@foo", but now special variables are accessed using "#foo". However, it is important to note that "#foo" does NOT access the request attributes. Because XWork is not built only for the web, there is no concept of "request attributes", and thus "#foo" is merely a request to another object in the OgnlContext other than the root.

Old Expression

New Expression

foo/blah

foo.blah

foo/someMethod()

foo.someMethod() <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5bc00f58-c578-40cb-aeec-42620a211793"><ac:plain-text-body><![CDATA[

../bar/blah

[1].bar.blah ]]></ac:plain-text-body></ac:structured-macro>

@baz

not directly supported, but #baz is similar <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8afd611f-fde9-4788-a9d4-852c5d306d6d"><ac:plain-text-body><![CDATA[

.

top or [0] ]] ></ac:plain-text-body></ac:structured-macro>

Struts 2 Named Objects

Struts 2 places request parameters and request, session, and application attributes on the OGNL stack. They may be accessed as shown below.

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="da8a3887-d692-4979-83c8-942ab99d9401"><ac:plain-text-body><![CDATA[

name

value

#parameters['foo'] or #parameters.foo

request parameter ['foo'] (request.getParameter())

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9998c4c1-c8af-44b1-b5f7-ebd203b6c2b9"><ac:plain-text-body><![CDATA[

#request['foo'] or #request.foo

request attribute ['foo'] (request.getAttribute())

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5daa8cfd-2781-4a27-9580-4b83022cab04"><ac:plain-text-body><![CDATA[

#session['foo'] or #session.foo

session attribute 'foo'

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0598bac1-3358-46d4-bcc3-eabc48e92d6d"><ac:plain-text-body><![CDATA[

#application['foo'] or #application.foo

ServletContext attributes 'foo'

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="022142b9-2207-449e-b3d2-9b205e59f76e"><ac:plain-text-body><![CDATA[

#attr['foo'] or #attr.foo

Access to PageContext if available, otherwise searches request/session/application respectively]]></ac:plain-text-body></ac:structured-macro>