Versions Compared

Key

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

...

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

@see 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 it isn't overriden in xwork.xml to be something else), it will get redirected to, in this case to www.google.com. Internall

// TODO: will finnish remaining latter (smile)

+ 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>

ActionMapperFactory

You can define your own ActionMapper by configuring the ActionMapperFactory:

...