You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

ActionMapper

Error formatting macro: snippet: java.lang.NullPointerException

DefaultActionMapper

By default, the DefaultActionMapper is used:

Error formatting macro: snippet: java.lang.NullPointerException

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 +

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

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

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

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

Error formatting macro: snippet: java.lang.NullPointerException

Possible uses of the ActionMapper include defining your own, cleaner namespaces, such as URLs like /person/1, which would be similar to a request to /getPerson.action?personID=1 using the DefaultActionMapper.

  • No labels