Mentawai Web Framework

Configuration Styles

Mentawai's programmatic approach to configuration, gives you total freedom, flexibility and power inside your configuration files. You can refactor, create new methods, static variables, loops, use inheritance to extends ApplicationManager, etc. From that freedom, two configuration styles have emerged from Mentawai, and are now fully supported in version 1.2.

The Java style, more verbose and more clear:

import org.mentawai.core.*;
import calculator.*;

public class ApplicationManager extends org.mentawai.core.ApplicationManager {
	
    public void loadActions() {
        
        setDebugMode(true);
        
        ActionConfig ac = new ActionConfig("/calc", CalcAction.class);
        ac.addConsequence(SUCCESS, new Forward("/calc.jsp"));
        ac.addConsequence(ERROR, new Forward("/calc.jsp"));
        
        ac.addFilter(new CalcValidator());
        ac.addFilter(new CalcConverter());
        
        addActionConfig(ac);
            
    }
}

The Ruby style, less verbose and less clear:


import org.mentawai.core.*;
import calculator.*;

public class ApplicationManager extends org.mentawai.core.ApplicationManager {
	
    public void loadActions() {
    
        setDebugMode(true);
        
        action("/calc", CalcAction.class)
        
            .on(SUCCESS, fwd("/calc.jsp"))
            .on(ERROR, fwd("/calc.jsp"))
            
            .filter(new CalcValidator())
            .filter(new CalcConverter());
    
    }
}

You can also create your own style, mix the above two styles and do whatever you want with your configuration. If you do something wrong, chances are the compiler will tell you. You can also refer to the javadocs for the syntax and possibilities.