GUI Commands User GuideVersion 2.1 |
||
Listeners and InterceptorsActionCommands support both listeners and a simple interceptor mechanism. Command listeners and notified both before and after a command is executed. Interceptors are notified before and after but have the opportunity to cancel the execution of the command. The following is an interceptor example:
command.addInterceptor(new ActionCommandInterceptor()
{
public boolean beforeExecute(ActionCommand command)
{
// return true to continue with the command execution
return true;
}
public boolean afterExecute(ActionCommand command)
{
...
}
}
Command listeners are very similar but follow the standard event listener style as the following example shows:
command.addCommandListener(new ActionCommandListener()
{
public void beforeExecute(ActionCommandEvent event)
{
...
}
public boolean afterExecute(ActionCommandEvent event)
{
...
}
}
|
||