Copyright (C) 2003 Philip Dorrell
MACAW standards for Methods And Classes All Webified. It is a Java application framework layered over Freemarker. It also includes a basic integration with Hibernate, which is contained within the macaw.database package, but this is merely to wrap method invocations within transactions: a similar wrapping can be defined for any other persistence framework.
In lieu of more substantial documentation which is yet to be written, the best way to find out more about MACAW is to look at the application that it was initially written for, which is Womcat Bookmarks. Currently the Womcat Bookmarks application source code comes bundled with the installer.
The main concept behind MACAW is that each web page is in some sense about an application object. Following this line of thinking, each HTML form submission maps to a method call on an application object.
There are three main layers in a MACAW application:
MACAW includes the following:
<@form object=object.manager method="sendMessage"/> <input type="text" name="p.text" cols="60"/> <@resultPage page="MessageSent"/> </@form>
The ".manager" property would correspond to a method in class WEmployee:
public WManager var_manager() {
// get manager somehow
}
"var_" is a prefix indicating a method used to get a property value of a webified object.
The form "method" attribute of "sendMessage" corresponds to invoking the following method:
public SimpleHash web_sendMessage_text_U (String text) throws Exception {
WMessage message = // send a message to the manager somehow
return message.getResult ("Message sent");
}
The "p.text" parameter gets mapped to the "text" parameter of the method. The "_text" gets appended onto the Java method name because Java's run-time reflection doesn't know anything about parameter names (they get lost during compilation). A standard mapping is defined for java.lang.String parameters.
"web_" is a general prefix indicating methods to be invoked from forms. The "_U" specifies that the method is an "update" method which can only be invoked from a form which is verified to have been created by the application itself. (This is to protect against the "Hostile URL" problem where links or forms from one web page attempt to access an internal web application.)
"getResult" is a standard method that wraps a webified object into a Freemarker template in the standard way expected by the Freemarker templates. Thus the returned template is a map that maps "object" to the WMessage object and "message" to "Message sent".
You can also use a @result tag to override the result object used to determine the page displayed after submitting the form. For example:
<@form object=object method="addChild"> <input type="text" name="p.child" cols="60"/> <@result object=object/> <@form>
Here the webified method "addChild" returns a result that wraps the newly created child, but actually we want to redisplay the current object. The "<@result object=object/>" tag over-rides the object returned by the method.
Latest version: macaw.v1.1.jar
The conventions used to map template properties and form methods and parameters to Java methods are a bit clunky. One particular problem is that compiled Java method parameters do not have names, which is of course incompatible with HTML form parameters that are explicitly named. The MACAW framework is defined in terms of interface classes WebifiedApplication, WebifiedClass, WebifiedObject and WebifiedMethod. The conventions given above are contained within the default implementations of these interfaces provided in the framework. This leaves open the possibility of using Java attributes, when they become available, or using some existing Java extension that does attributes, as an alternative way of exposing methods with named parameters (and update/non-update flag) to the templates.
MACAW is licenced under the LGPL