blob: 23b1b41ff1bdf99e8e41fc1c48fbc33ce0dd677e [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Content Stylesheet for Site -->
<!-- start the processing -->
<!-- ====================================================================== -->
<!-- Main Page Section -->
<!-- ====================================================================== -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="author" value="Jon S. Stevens">
<meta name="email" value="jon@latchkey.com">
<title>Velocity - You make the decision - Sample Application</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td align="left">
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" border="0"/></a>
</td>
<td align="right">
<a href="http://jakarta.apache.org/velocity/"><img src="../images/logo.gif" alt="Velocity" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr>
<!-- LEFT SIDE NAVIGATION -->
<td valign="top" nowrap="true">
<p><strong>About</strong></p>
<ul>
<li> <a href="../index.html">Overview</a>
</li>
<li> <a href="../getting-started.html">Getting Started</a>
</li>
<li> <a href="../install.html">Install</a>
</li>
<li> <a href="../design.html">Design</a>
</li>
<li> <a href="../contributors.html">Contributors</a>
</li>
<li> <a href="../code-standards.html">Coding Standards</a>
</li>
<li> <a href="../license.html">License</a>
</li>
<li> <a href="../todo.html">TODO</a>
</li>
</ul>
<p><strong>Guides</strong></p>
<ul>
<li> <a href="../user-guide.html">User's Guide</a>
</li>
<li> <a href="../developer-guide.html">Developer's Guide</a>
</li>
<li> <a href="../vtl-reference-guide.html">VTL Reference Guide</a>
</li>
</ul>
<p><strong>Comparisons</strong></p>
<ul>
<li> <a href="../ymtd/ymtd.html">YMTD</a>
</li>
<li> <a href="../differences.html">VM/WM Differences</a>
</li>
</ul>
<p><strong>Tools</strong></p>
<ul>
<li> <a href="../anakia.html">Anakia</a>
</li>
<li> <a href="../texen.html">Texen</a>
</li>
<li> <a href="../migration.html">Migration to Velocity</a>
</li>
</ul>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>Sample Application</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;%-- toolview.jsp --%&gt;
&lt;%
String title = &quot;Tool Listing&quot;;
String deck = &quot;A list of content creation tools&quot;;
String desc = &quot;Without tools, people are nothing more than animals.&quot;;
%&gt;
&lt;%@ include file=&quot;/header.jsp&quot; %&gt;
&lt;%@ page session=&quot;false&quot; %&gt;
&lt;%@ page errorPage=&quot;/errorTaker.jsp&quot; %&gt;
&lt;jsp:useBean id=&quot;toolbean&quot; class=&quot;ToolBean&quot; scope=&quot;application&quot;&gt;
&lt;jsp:setProperty name=&quot;toolbean&quot; property=&quot;toolsFile&quot;
value='&lt;%= application.getInitParameter(&quot;toolsFile&quot;) %&gt;' /&gt;
&lt;/jsp:useBean&gt;
&lt;%
Tool[] tools = toolbean.getTools(request.getParameter(&quot;state&quot;));
for (int i = 0; i &lt; tools.length; i++) {
Tool tool = tools[i];
%&gt;
&lt;HR SIZE=2 ALIGN=LEFT&gt;
&lt;H3&gt;
&lt;%= tool.name %&gt;
&lt;% if (tool.isNewWithin(45)) { %&gt;
&lt;FONT COLOR=&quot;#FF0000&quot;&gt;&lt;B&gt; (New!) &lt;/B&gt;&lt;/FONT&gt;
&lt;% } else if (tool.isUpdatedWithin(45)) { %&gt;
&lt;FONT COLOR=&quot;#FF0000&quot;&gt;&lt;B&gt; (Updated!) &lt;/B&gt;&lt;/FONT&gt;
&lt;% } %&gt;
&lt;/H3&gt;
&lt;A HREF=&quot;&lt;%= tool.homeURL %&gt;&quot;&gt;&lt;%= tool.homeURL %&gt;&lt;/A&gt;&lt;BR&gt;
&lt;%= tool.comments %&gt;
&lt;% } %&gt;
&lt;%@ include file=&quot;/footer.jsp&quot; %&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
Because of JSP whitespace preservation rules you must be careful when
writing if/else statements with scriptlets. The following code would
*not* work:
&lt;% if (tool.isNewWithin(45)) { %&gt;
&lt;FONT COLOR=#FF0000&gt;&lt;B&gt; (New!) &lt;/B&gt;&lt;/FONT&gt;
&lt;% } %&gt;
&lt;% else if (tool.isUpdatedWithin(45)) { %&gt;
&lt;FONT COLOR=#FF0000&gt;&lt;B&gt; (Updated!) &lt;/B&gt;&lt;/FONT&gt;
&lt;% } %&gt;
With this code the background servlet would attempt to print a new line
between the if and else clauses, causing the obscure compile error:
'else' without 'if'.
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
Another great Jason quote:
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
One thing to watch out for: On some servers (including Tomcat 3.XXX) if
you have a bean with a scope of &quot;session&quot; or &quot;application&quot; and you
change the bean class implementation, you may get a ClassCastException
on a later request. This exception occurs because the generated servlet
code has to do a cast on the bean instance as it's retrieved from the
session or application, and the old bean type stored in the session or
application doesn't match the new bean type expected. The simplest
solution is to restart the server.
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
It is the belief of the Velocity developers that you should not have to
specially code your applications to work around issues that are related
directly to Java.
</p>
<hr noshade="true" size="1" />
<p>
On to the Velocity version...
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
## toolview.vm
#set ($title = &quot;Tool Listing&quot;)
#set ($deck = &quot;A list of content creation tools&quot;)
#set ($desc = &quot;Without tools, people are nothing more than animals.&quot; )
#parse (&quot;header.vm&quot;)
$toolbean.setToolsFile($application.getInitParameter(&quot;toolsFile&quot;))
#set ($tools = $toolbean.getTools($request.getParameter(&quot;state&quot;)))
#foreach ($tool in $tools)
&lt;HR SIZE=2 ALIGN=LEFT&gt;
&lt;H3&gt;
$tool.Name
#if ($tool.isNewWithin(45))
&lt;FONT COLOR=&quot;#FF0000&quot;&gt;&lt;B&gt; (New!) &lt;/B&gt;&lt;/FONT&gt;
#elseif (tool.isUpdatedWithin(45))
&lt;FONT COLOR=&quot;#FF0000&quot;&gt;&lt;B&gt; (Updated!) &lt;/B&gt;&lt;/FONT&gt;
#end
&lt;/H3&gt;
&lt;A HREF=&quot;$tool.homeURL&quot;&gt;$tool.homeURL&lt;/A&gt;&lt;BR&gt;
$tool.comments
#end
#parse (&quot;footer.vm&quot;)
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
You make the decision.
</p>
<p>
<strong>[ <a href="ymtd-javabeans.html">JavaBeans</a> &lt;- Previous |
Next -&gt; <a href="./ymtd-taglibs.html">Taglibs</a> ]
</strong></p>
</blockquote>
</td></tr>
</table>
</td>
</tr>
<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright &#169; 1999-2001, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->