public class Application
A generic Piccolo application. Application should be initialized with XMLParamProcessor from
PiccoloServlet. This class is XMLParamAware and has special handling for xml parameters. service
elements are used to register services to application (parsed according to normal XMLParamProcessor rules).
actionmap element contains the action map for the application. It can contain any number of mapentry elements
which each contain a key element and an action element. Key element should contain the string used as the
action key and action element is parsed with KMLParamProcessor and should produce the action object.
Depending on the used action, you might need to pass some parameters to the action.
templates element is used to specify the used templates. It can contain any number of template elements.
Each of these are parsed with XMLParamProcessor. Usually these will be VelocityTemplates (an XMLParamAware class)
in which case each template element should contain the following elements (each having a plain string value):
key, version, mimetype, encoding, template, caching. Of these, the value of caching should be either true or false.
You can use other kinds of templates too, they just need to implement the Template interface.
properties element is used to specify the application properties (retrieved with getProperty). It is parsed
with MapParser, so it may contain any number of property elements each containing key and value elements.
Both of these are parsed with XMLParamProcessor, so they may be any objects.
Finally, the application element may contain any number of contextobject elements. Each is parsed with
XMLParamProcessor. Context objects are returned by getDefaultContext which is usually called to initialize
Velocity contexts. Thus these objects are usable in Velocity templates. The key for the object in the contexct
is taken from key attribute (note that this is without namespace) in the contextobject element.
Some special actions may be specified in the action map. Action with key "invaliduser" is executed when
the request does not specify a valid user (e.g. wrong password). However, note that the current
getUser implementation (which is used to get the user specified by the request) always returns a user so
unless you override getUser, this action will never be called. Action with key "invalidaction" is executed
when an invalid action key is specified in the request. If these actions are not specified but the event
arises where they would be used, a log entry for the event is created and nothing is returned to the client
who made the request.
Some of the properties are also specifically used by Application. "defaultlang" property can be used
to specify the language returned by getDefaultLang, which in turn is used by getUser, when no language
is specified in the request parameters.
public java.util.HashMap getDefaultContext(User user)
Returns a default context that should be used as the base for most Velocity templates. The returned
context will contain all context objects specified in the XML parameters and this Application with key
"application", the user provided in the parametrs with key "user" and the language of the user with
public void xmlParamInitialize(org.w3c.dom.Element element,
XMLParamAware implementation. Handles initialization from XML parameters.