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="5295fc7f-fef6-408c-ac91-0e33407e4452"><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="9cf0e6de-a884-4873-b1ed-9d25078d19b5"><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="37eb1c5e-42a7-420f-8202-cb8776d6a239"><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="19c077da-d760-404f-8da3-da36b799537c"><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="d7efdc11-b112-42bd-af74-86285dbe89ef"><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="7726dec2-0b48-4430-bad0-e6b9d69c75da"><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="2d2fa291-a71e-471b-836c-ac822d61f900"><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="214746b9-683d-4a62-ab5c-99d232f0949b"><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="4aa39be6-95eb-47ee-ac19-2a372dbf0195"><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>