Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
{snippet:id=javadoc|javadoc=true|url=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper}

Parameter-support of DefaultActionMapper

To help with dealing with buttons in WW, we've added in the DefaultActionMapper (and we encourage other ActionMappers to use this technique as well) the ability to name a button with some predefined 'Parameter-Support' prefix and have them perform alter the execution behaviour. Below are the details

Wiki Markup
{snippet:id=method|javadoc=true|url=

...

com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper

...

+ METHOD PREFIX +

Code Block

  <ww:form name="baz">
    <ww:textfield label="Enter your name" name="person.name"/>
    <ww:submit value="Create person"/>
    <ww:submit name="method:anotherMethod" value="Cancel"/>
  </ww:form>

With method-prefix, instead of calling baz action's execute() method (by default if it isn't overriden in xwork.xml to be something else), the baz action's anotherMethod() will be called. A very elegant way determine which button is clicked. Alternatively, one would have submit button set a particular value on the action when clicked, and the execute() method decides on what to do with the setted value depending on which button is clicked.

+ ACTION PREFIX +

Code Block

<ww:form name="baz">
    <ww:textfield label="Enter your name" name="person.name"/>
    <ww:submit value="Create person"/>
    <ww:submit name="action:anotherAction" value="Cancel"/>
</ww:form>

With action-prefix, instead of executing baz action's execute() method (by default if it isn't overriden in xwork.xml to be something else), the anotherAction action's execute() method (assuming again if it isn't overriden with something else in xwork.xml) will be executed.

+ REDIRECT PREFIX +

Code Block

<ww:form name="baz">
    <ww:textfield label="Enter your name" name="person.name"/>
    <ww:submit value="Create person"/>
    <ww:submit name="redirect:www.google.com" value="Cancel"/>
</ww:form>

With redirect-prefix, instead of executing baz action's execute() method (by default it isn't overriden in xwork.xml to be something else), it will get redirected to, in this case to www.google.com. Internally it uses ServletRedirectResult to do the task.

+ REDIRECT ACTION PREFIX +

Code Block

<ww:form name="baz">
    <ww:textfield label="Enter your name" name="person.name"/>
    <ww:submit value="Create person"/>
    <ww:submit name="redirect-action:dashboard" value="Cancel"/>
</ww:form>

...

}
Wiki Markup
{snippet:id=method-example|javadoc=true|url=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper}
Wiki Markup
{snippet:id=action|javadoc=true|url=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper}
Wiki Markup
{snippet:id=action-example|javadoc=true|url=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper}
Wiki Markup
{snippet:id=redirect|javadoc=true|url=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper}
Wiki Markup
{snippet:id=redirect-example|javadoc=true|url=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper}
Wiki Markup
{snippet:id=redirect-action|javadoc=true|url=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper}
Wiki Markup
{snippet:id=redirect-action-example|javadoc=true|url=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper}

ActionMapperFactory

You can define your own ActionMapper by configuring the ActionMapperFactory:

...