<?xml version="1.0"?>

<!--
   Copyright 2000-2004 The Apache Software Foundation

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->


<document>

 <properties>
  <title>Velocity Design</title>
  <author email="jvanzyl@zenplex.com">Velocity Documentation Team</author>
 </properties>

 <body>

 <section name="Design">

 <p>
    Velocity is a Java-based template engine. It can be used as a
    standalone utility for generating source code, HTML, reports,
    or it can be combined with other systems to provide template
    services. Velocity will be tightly integrated with the
    <a href="http://java.apache.org/turbine">Turbine</a>
    web application framework. Velocity-Turbine
    provide a template service by which web applications may be
    developed according to a true MVC model.
 </p>

 <p>
    Velocity has a myriad of potential uses -- generating SQL, PostScript,
    or Java source code from templates -- but web developers looking for
    a viable alternative to
    <a href="http://www.php.net/">PHP</a> and
    <a href="http://java.sun.com/products/jsp/">Java
    Server Pages</a> (JSPs) are expected to be its principle user group.
 </p>

 <p>
    Velocity allows web page designers to embed simple yet powerful script
    elements in their web pages. These script elements work
    in conjunction with a Context object, which is defined in Java code.
    A context object--essentially a hashtable that provides get and set
    methods for retrieving and setting objects by name within the Context
    --provides a &quot;hook&quot; from the Java code to the Velocity script
    elements. These script elements allow a web designer to retrieve
    objects from the Context and insert these into a web page as text
    values. The web designer has some control over looping (for each)
    and conditional statements (if/else).
 </p>

 <p>
    Velocity enforces a Model-View-Controller (MVC) style of development
    by separating Java code from HTML template code. Unlike JSPs,
    Velocity does not allow Java code to be embedded in pages. Unlike PHP,
    Velocity does not implement features with other functions. The MVC
    approach is one of Velocity's great strengths, and allows for more
    maintainable and better-designed web pages.
 </p>

 <p>
    Although MVC-style development can sometimes lead to longer incubation
    periods for web sites, particularly if the developers involved are new
    to MVC, this approach saves time over the long term (believe us, we have
    been doing this for a long time now). The MVC abstraction prevents web page
    designers from messing with a software engineer's Java code, and
    programmers from unduly influencing the look of web sites. Velocity enforces
    a contract that defines what roles people play in the web site development
    process.
 </p>

 <p>
    Velocity uses a grammar-based parser generated by
    <a href="http://www.metamata.com/javacc/">JavaCC</a> (Java Compiler
    Compiler) using the JJTree extension to create an Abstract Syntax Tree.
 </p>

 <p>
    Velocity's design concept is borrowed from <a
    href="http://www.webmacro.org/">WebMacro</a>. Those involved in the
    Velocity project acknowledge and appreciate the development and design work
    that went into the WebMacro project.
 </p>

</section>

</body>
</document>
