Framework

WW provides a way for you to configure the framework by property files. Through this technique, you have the ability to configure how WW behaves. By default, WW looks for two property files, webwork.properties and default.properties, to find webwork.configuration.properties property. The value of this property is used to load the actual configuration files that will configure WW.

The default value for webwork.configuration.properties is views,webwork,webwork/default. This comma separated list tells WW to look for the property files views.properties, webwork.properties, and default.properties. You will define the file webwork.properties to override any property setting in default.properties and to define new properties for your application. You will provide views.properties to define your views.

Listed below are properties that WW recognizes:

Properties

See Default Configuration for an example configuration setting that WW uses by default. You may override any item you see fit.

How do I override a property?

Overriding WW's property settings is easy. By default, it looks for webwork.properties file in your classpath. Normally, you would place this file in WEB-INF/classes. In this file, you just add any WW property you want to override. In addition, you can add other properties that your programs may need in this file and get access to it via webwork.config.Configuration's static methods.

For instance, we can override webwork.action.packages to include a company's (Acme) actions by providing a webwork.properties file in the web application's classpath with this line -

webwork.action.packages=com.acme.action

Views

views.properties defines your alias to Action or JSP mappings. This allows you to abstract references to Actions and JSP. For instance, you could define an alias testfoo.action to an action named Test. In this example, WW will resolve the alias testfoo.action from the views.properties file to the action Test.

<form action="<webwork:url page="testfoo.action"/>" method="POST">

Listed below is an example of a views.properties file. Note, Test!foo defines a command driven action. This means alias testfoo.action will cause WW to retrieve action Test and invoke method doFoo. The return value will be success and WW will then resolve alias testfoo.success and test.jsp will be rendered. See Commands for more information about action commands.

testfoo.action=Test!foo
testfoo.success=test.jsp

If you prefer to define your view in an XML file rather than a properties file, you do so by providing an XML file named actions.xml. By default, WW will read in any views defined in this file. Here is an example of an actions.xml file.

Here is an example actions.xml file.

The DTD for this XML configuration file can be found in the file /etc/actions.dtd in your WebWork distribution.

The algorithm used to find a view from your configuration file is as follows:

    First, the configuration is checked for a actionName.viewName entry. If found, then that is used. If not found, then parts of the action name are removed until a match is found. For example, suppose we have a view mapping shown below and an action foo.bar was executed and it returned SUCCESS, WW would look for foo.bar.success. However, it would not find a match so the algorithm would remove bar and look for foo.success and it will find a match. This allows you to define global mappings for login, error, success, or whatever you want.
foo.success=foo.jsp

Logger

WW uses commons-logging as its logger. This is a a wrapping logger that will use log4j or the JDK 1.4 logging API depending on which is available. The configuration of commons-logging happens through a discovery mechanism; if log4j is found in your classpath then the log4j logging system will be loaded, and an appropriate log4j.properties file should exist in your classpath. An example of a log4j.properties configuration file is provided below.

# A log4j properties file
### The WebWork console appender
log4j.category.webwork=DEBUG,WebWorkConsole
log4j.additivity.webwork=false
log4j.appender.WebWorkConsole=org.apache.log4j.ConsoleAppender
log4j.appender.WebWorkConsole.Threshold=DEBUG
log4j.appender.WebWorkConsole.layout=org.apache.log4j.PatternLayout
log4j.appender.WebWorkConsole.layout.ConversionPattern=[%x (%c{1})] %m%n
log4j.category.webwork.action.test=INFO
How do I log from within my Actions?

Most application's Actions will extend the base action ActionSupport. This action provides a protected log attribute for you to use to write out logs from within your actions.

How do I log to a file?

Customize your logging file and add suitable appenders or handlers that will log to a file. See here for information on the JDK 1.4 logging API (with some examples on how to log to a file), or for information on configuring log4j.