5.5. Action implementations

While writing action code as POJO logic is the most common, there are several other action implementation options. Sometimes you need to write action code that needs access to the flow context. You can always invoke a POJO and pass it the flowRequestContext as an EL variable. Alternatively, you may implement the Action interface or extend from the MultiAction base class. These options provide stronger type safety when you have a natural coupling between your action code and Spring Web Flow APIs. Examples of each of these approaches are shown below.

Invoking a POJO action

<evaluate expression="pojoAction.method(flowRequestContext)" />	
        	
public class PojoAction {
    public String method(RequestContext context) {
        ... 
    }
}
			

Invoking a custom Action implementation

<evaluate expression="customAction" />	
        	
public class CustomAction implements Action {
    public Event execute(RequestContext context) {
        ... 
    }
}
			

Invoking a MultiAction implementation

<evaluate expression="multiAction.actionMethod1" />
	
        	
public class CustomMultiAction extends MultiAction {
    public Event actionMethod1(RequestContext context) {
        ... 
    }

    public Event actionMethod2(RequestContext context) {
        ... 
    }

    ...
}