Mentawai Web Framework

Action Chaining

The consequence of a mentawai result can be a chain to another action. For example, one action may update an user profile and then chain to the action that displays it.

To define action chaining in mentawai, you use the org.mentawai.core.Chain which inherits from org.mentawai.core.Consequence. Check the ApplicationManager code below for an example:

public class ApplicationManager extends org.mentawai.core.ApplicationManager {
	public void loadActions() {
		ActionConfig ac2 = new ActionConfig("/Action2", Action2.class);
		ac2.addConsequence(Action2.SUCCESS, new Forward("/show.jsp"));
		ActionConfig ac1 = new ActionConfig("/Action1", Action1.class);
		ac1.addConsequence(Action1.SUCCESS, new Chain(ac2));

Important things you should know about action chaining:

  • When you chain an action, the input and output of the first action is passed to the second action.

  • All actions in the chain are executed with all their filters and global filters. Therefore if you have a global filter and you chain an action, the filter will be executed twice, for the first action and for the second action.