Wouldn't it be good if you could see everything that happens behing the scene inside the framework? Which action is being executed, what filters are being applied, how does the action input/output looks like after each step? Mentawai will reveal its magic through its debug mode.
To see the Debug Mode in action, play with the reference application by clicking here.
Setting up a servlet filter in the web.xml:
The Debug Mode requires a servlet filter to intercept every request to the controller. In your WEB-INF/web.xml file you should do:
<filter> <filter-name>DebugFilter</filter-name> <filter-class> org.mentawai.util.DebugServletFilter </filter-class> </filter> <filter-mapping> <filter-name>DebugFilter</filter-name> <url-pattern>*.jsp</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping>
Turning on the debug mode in the application manager:
Then you can turn it on and off easily inside your application manager:
@Override public void init(Context application) { setDebugMode(true); //or setDebugMode(true, true); // the second boolean here is to show the info in a HTML comment }
TIP: If the Debug Mode output is messing with your site layout you can make it appear inside a HTML comment with the second method above.
Using the environment properties:
It is probably a good idea to turn the Debug Mode on or off according to your environment, so for example for development you will keep it on but for production it would be turned off. So the environment properties are a good match here:
@Override public void init(Context application) { Props props = getProps(); setDebugMode(props.getBoolean("debug_mode")); //or setDebugMode(props.getBoolean("debug_mode"), props.getBoolean("debug_mode_in_html_comment")); }