blob: f6d6467a5e5ad35c1068abe801627e9e7cfc370e [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../help.css">
</head>
<body>
<h1>Velocity</h1>
Velocity is a Java-based template framework which provides the default HTML rending engine
for Click. Velocity is very easy to learn, simple to use, and is also very capable.
<p>
<a href="http://velocity.apache.org/">Velocity</a> is an open source
Apache project licensed using the <a href="../LICENSE.txt">Apache</a> Software License.
<p>
Velocity's comprehensive online documentation is included in this distribution.
<ul>
<li><a href="user-guide.html">Users Guide</a> - Velocity users guide
</li>
<li><a href="developer-guide.html">Developers Guide</a> - Velocity developers configuration guide
</li>
<li><a href="vtl-reference-guide.html">VTL Reference</a> - Velocity Template Language (VTL) reference guide
</li>
</ul>
<p>&nbsp;</p>
<h2>Object References</h2>
With Click you add objects to your page template using the Page's model. You can then access these objects
using Velocities <span class="red">$</span> reference notation. By default the ClickServlet adds the
following objects to page templates:
<ul style="margin-bottom: 1.5em;">
<li>
any public Page fields using the fields name
</li>
<li><span class="st">context</span> &nbsp; - &nbsp;
the Servlet context path, e.g. <span class="blue">/mycorp</span>
</li>
<li><span class="st">cssImports</span> &nbsp; - &nbsp;
the CSS imports and style blocks to include in the pages header.
Please see <a href="../click-api/org/apache/click/util/PageImports.html">PageImports</a>
for more details.
</li>
<li><span class="st">format</span> &nbsp; - &nbsp;
the <a href="../click-api/org/apache/click/util/Format.html">Format</a>
object for formatting the display of objects.
</li>
<li><span class="st">imports</span> &nbsp; - &nbsp;
the CSS and JavaScript imports to include in the pages header.
Please see <a href="../click-api/org/apache/click/util/PageImports.html">PageImports</a>
for more details.
</li>
<li><span class="st">jsImports</span> &nbsp; - &nbsp;
the JavaScript imports and script blocks to include in the pages footer.
Please see <a href="../click-api/org/apache/click/util/PageImports.html">PageImports</a>
for more details.
</li>
<li><span class="st">messages</span> &nbsp; - &nbsp;
the <a target="topic" href="../click-api/org/apache/click/util/MessagesMap.html">MessagesMap</a> adaptor
for the Page <a href="../click-api/org/apache/click/Page.html#getMessage(java.lang.String)">getMessage()</a>
method.
</li>
<li><span class="st">path</span> &nbsp; - &nbsp;
the <a href="../click-api/org/apache/click/Page.html#path">path</a>
of the page template to render.
</li>
<li><span class="st">request</span> &nbsp; - &nbsp;
the pages <a class="external" target="_blank" href="http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpServletRequest.html">HttpServletRequest</a>
object.
</li>
<li><span class="st">response</span> &nbsp; - &nbsp;
the pages <a class="external" target="_blank" href="http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpServletResponse.html">HttpServletResponse</a>
object.
</li>
<li><span class="st">session</span> &nbsp; - &nbsp;
the <a target="topic" href="../click-api/org/apache/click/util/SessionMap.html">SessionMap</a> adaptor
for the users <a class="external" target="_blank" href="http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpSession.html">HttpSession</a>.
</li>
</ul>
In your page templates you can access object references using a dot path notation. For example:
<pre class="codeHtml">
Welcome: <span class="red">$</span><a target="topic" href="../click-api/org/apache/click/util/SessionMap.html">session</a>.user.fullName
</pre>
Or by using a more explicit Java notation:
<pre class="codeHtml">
Welcome: <span class="red">$</span><a target="topic" href="../click-api/org/apache/click/util/SessionMap.html">session</a>.get("user").getFullName()
</pre>
<h2>Directives</h2>
In Velocity directives are prefixed by a <span class="red">#</span> symbol. While
references access stuff, directives do stuff. The full set of Velocity directives are:
<ul style="margin-bottom: 1.5em;">
<li><a href="vtl-reference-guide.html#if">#if #elseif #else</a> &nbsp; - &nbsp;
output conditional on truth of statements.<p>
</li>
<li><a href="vtl-reference-guide.html#foreach">#foreach</a> &nbsp; - &nbsp;
loops through a list of objects.<p>
<p>
</li>
<li><a href="vtl-reference-guide.html#macro">#macro</a> &nbsp; - &nbsp;
allows users to define a Velocimacro (VM), a repeated segment of a VTL template, as required. <p>
</li>
<li><a href="vtl-reference-guide.html#set">#set</a> &nbsp; - &nbsp;
establishes the value of a reference.<p>
</li>
<li><a href="vtl-reference-guide.html#include">#include</a> &nbsp; - &nbsp;
renders local file(s) that are not parsed by Velocity.<p>
</li>
<li><a href="vtl-reference-guide.html#parse">#parse</a> &nbsp; - &nbsp;
renders a local template that is parsed by Velocity. <p>
</li>
<li><a href="vtl-reference-guide.html#stop">#stop</a> &nbsp; - &nbsp;
stops the template engine. <p>
</li>
</ul>
<!-- FOOTER -->
<div id="footer">
<hr/>
<p>
<a target='_blank' href='http://www.apache.org' title='Apache Software Foundation'>
<img id="asf-logo" src="http://www.apache.org/images/asf-logo.gif" alt="Apache Software Foundation"/>
</a>
Copyright &copy; 2001-2010 Apache Software Foundation. Apache Click,
Click, Apache, the Apache feather logo, and the Apache Click project logo are
trademarks of The Apache Software Foundation.
<a href="http://cayenne.apache.org/privacy-policy.html">Privacy policy.</a>
</p>
</div>
</body>
</html>