The Maverick FAQ

    General

  1. Does the world really need yet another MVC web publishing framework?
  2. Why XSLT?
  3. Do I need to use XSLT?
  4. What about view templating systems other than XSLT or JSP?
  5. Why did you choose the name Maverick?
  6. Huh?
  7. Installing Maverick

  8. What servers does Maverick work with?
  9. Does Maverick work with Tomcat 3.x?
  10. Why does Maverick require the Servlet 2.3 API?
  11. Configuring Maverick

  12. How do I configure a view to return static html?
  13. How do I do transforms on static XML?
  14. What are the possible Servlet Init Params?
  15. Velocity

  16. How can I specify a property file for initializing the Velocity Runtime?
How do I configure a view to return static html?

Just use the <source-document> element. You can give it the URI of a document and it will be resolved as a simple forward. Here is an example:

  <command name="stuff">
    <view>
      <document>stuff.html</document>
    </view>
  </command>

How do I do transforms on static XML?

You can use the <source-document> element and add a pipeline too:

  <command name="stuff">
    <view>
      <document path="stuff.xml">
        <transform path="file1.xsl" />
        <transform path="file2.xsl" />
      </document>
    </view>
  </command>

What are the possible Servlet Init Params?

maxTransformsEnabled: true/false

Whether or not to allow the "mavMaxTransforms" parameter to halt the transformation pipeline prematurely. The default is false. Warning! This should only be enabled on private/test sites because it allows anyone to view the raw XML view of your bean data. In the case of friendbook, this includes users' passwords!

	<init-param>
		<param-name>maxTransformsEnabled</param-name>
		<param-value>true</param-value>
	</init-param>


defaultContentType: [String]

The default content type used for responses back to browser agent. It can be overriden for specific view elements by specifying a content-type attribute. Also, halted transformations are always returned as text/xml. This param doesn't really need to be here; if absent, text/html is assumed.

	<init-param>
		<param-name>defaultContentType</param-name>
		<param-value>text/html</param-value>
	</init-param>


defaultRequestCharset: [String]

The default charset used to decode request parameters. This only applies to request parameters, not to output encoding. If absent, the web container default is used.

	<init-param>
		<param-name>defaultRequestCharset</param-name>
		<param-value>UTF-8</param-value>
	</init-param>


reloadCommand: [String]

The command which causes Maverick to reload the maverick.xml config data and any cached/precompiled XSLT templates. Commands are still processed with the old data while the reloading is in progress, so it isn't too big of a deal if your users call this. It wastes CPU resources, though, so you might want to change the command to something more obscure. If this param is not defined, the reload command is disabled.

	<init-param>
		<param-name>reloadCommand</param-name>
		<param-value>reload</param-value>
	</init-param>


velocityProperties: [String]

The property file used to initialize the Velocity Runtime Engine. NOTE: If no init-param matching this name is found then the 'file.resource.loader.path' Velocity property is set to the current web application root. This ensures that by default relative refernces to source files (<source-velocity>file1.vm</source-velocity>) can be the resolved by resource loader.

	<init-param>
		<param-name>velocityProperties</param-name>
		<param-value>velocity.properties</param-value>
	</init-param>


preloadTemplates: [String:t/f]

The pre-load templates params indicated when templates should be loaded and compiled. Setting this to false basically makes this operation lazy. NOTE: Setting this to false causes templates to be loaded and compiled on every request.

	<init-param>
		<param-name>preloadTemplates</param-name>
		<param-value>true/false</param-value>
	</init-param>

Does the world really need yet another MVC web publishing framework?

Yes. There are many MVC frameworks, but few provide either XSLT support or the proper view separation necessary to allow multiple template languages to be used. By and large most templating systems do the same thing, so a proper MVC framework should be agnostic about your preference. It is our belief that XSLT is an excellent choice for this purpose, but the only other framework we are aware of with sophisticated support for XSLT is the terribly complicated Cocoon.

Why XSLT?

Frameworks like Struts or WebWork use custom tag libraries to separate code from views. Unfortunately, custom tags are far too inflexible - for instance, try formatting a float as a percentage in one of the above frameworks without resorting to JSP scriptlets. Also, the kind of "templating" where you wrap content in an outer frame for consistent site look-and-feel is difficult with JSP and tags - take a look at Struts' template.tld tag library. These sorts of problems are solved by XSLT quite elegantly.

Do I need to use XSLT?

Not at all. You can use JSP views very much like you can with Struts. However, we provide no custom tags for iteration, etc. You can use JSP scriptlets or download someone else's tag libraries. Jakarta and Orion both offer some convenient tags. Alternatively you can use Velocity, which offers a simple, intuitive, and elegant template synatx.

What about view templating systems other than XSLT or JSP?

Maverick has been designed with extensibility in mind. Support for Velocity has been added with version 0.9.5. It would be easy to add support for other templating systems. If you want something, send a request to the mav-user mailing list.

Why did you choose the name Maverick?

Because it is a better name than Ambivalence.

Huh?

grep -i m.*v.*c /usr/share/dict/words

What servers does Maverick work with?

Maverick is tested with the latest versions of Orion and Tomcat 4. It should work with any servlet container that supports the Servlet 2.3 API.

Does Maverick work with Tomcat 3.x?

It is not officially supported, but it can be made to work with some limitation. Due to limitations in the Servlet 2.2 API, you cannot apply a transformation <pipeline> to <source-document> or <source-jsp>. So as long as you do not need to transform static (or jsp) documents, it will probably work. Don't bother trying the friendbook example, though :-)

Why does Maverick require the Servlet 2.3 API?

In order to run XSLT transformations on the output of a static or jsp generated document, Maverick must be able to intercept the result of RequestDispatcher.forward() before it is sent back to the client. The Servlet 2.2 API definition of the RequestDispatcher interface does not allow this to happen.

For a better understanding, see the code in org.infohazard.maverick.flow.ViewDocumentPiped and read the JavaDocs for RequestDispatcher.forward().

How can I specify a property file for initializing the Velocity Runtime?

A properties file can be specifies in the web.xml configution file. See the example below.

<servlet>
	...
	<init-param>
		<param-name>velocityProperties</param-name>
		<param-value>velocity.properties</param-value>
	</init-param>
	...