Commands are a useful feature of WebWork that allow you to use one action class to perform a variety of tasks.
A command allows you to specify do* methods to be invoked on your action, instead of doExecute. The power of commands is best illustrated with an example. Suppose your action handles a 'wizard' type component. This involves moving through a sequence of pages, performing various checks and validation on the way. At some point in the process, you would like to send an email.
you can achieve that through defining a doEmail
method in your action. Then in your form, you would simply
call this method by setting the url to youraction!email. The ! character is used to denote command execution, and any
do* command method can be invoked this way. Note that when a command is explicitly invoked, doValidation is not called.
If you need to validate input before calling a command, you will need to do so explicitly in your command method.