geirm       01/02/26 22:06:31

  Modified:    xdocs    developer-guide.xml
  Log:
  -Added additional and more info about build targets.
  - Sprinkled examples of catching the two new o.a.v.e exceptions for
  app use (w/o saying anything about them... it's a good start, I supposed)
  - Described the overridable methods of VelocityServlet.
  
  Revision  Changes    Path
  1.17      +54 -1     jakarta-velocity/xdocs/developer-guide.xml
  
  Index: developer-guide.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/xdocs/developer-guide.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- developer-guide.xml       2001/02/26 06:38:54     1.16
  +++ developer-guide.xml       2001/02/27 06:06:30     1.17
  @@ -94,7 +94,15 @@
         </li>
         <li>
           <code>docs</code> builds these docs in the <code>docs</code> directory
  +        using Velocity's <a href='anakia.html'>Anakia</a> XML transformation tool.  

  +        Allowing you to use
  +        Velocity templates in place of stylesheets
  +        - give it a try!
         </li>
  +      <li>  
  +        <code>jarsrc</code> bundles all the Velocity source code into a single
  +        jar, placed in the <code>bin</code> directory.
  +      </li>
         <li>
           <code>javadocs</code> builds the Javadoc class documentation in the
           <code>docs/apidocs</code> directory
  @@ -209,6 +217,14 @@
   {
      template = Runtime.getTemplate("mytemplate.vm");
   }
  +catch( ResourceNotFoundException rnfe )
  +{
  +   // couldn't find the template
  +}
  +catch( ParseErrorException pee )
  +{
  +  // syntax error : problem parsing the template
  +}
   catch( Exception e )
   {}
   
  @@ -416,7 +432,6 @@
   {
       public Template handleRequest( Context context )
       {
  -        Template template = null;
   
           String p1 = "Jakarta";
           String p2 = "Velocity";
  @@ -427,10 +442,20 @@
   
           context.put("list", vec );
   
  +        Template template = null;
  +
           try
           {
               template =  getTemplate("sample.vm");
           }
  +        catch( ResourceNotFoundException rnfe )
  +        {
  +          // couldn't find the template
  +        } 
  +        catch( ParseErrorException pee )
  +        {
  +          // syntax error : problem parsing the template
  +        }
           catch( Exception e )
           {}
   
  @@ -445,6 +470,34 @@
   it's identical to the basic code pattern we mentioned at the beginning of this 
guide.
   We take the context, add our application data, and return a template.
   </p>
  +<p>
  +For advanced users,  the VelocityServlet base class allows you to override parts of 
the handling of the request processing.  The following methods may be overridden. 
  +
  +<ul>
  +  <li> <code>Context createContext(HttpServletRequest request,  HttpServletResponse 
response )</code>
  +    Allows you to create the Context object yourself. This allows more advanced 
techniques, such as chaining
  +    or pre-loading with tools or data.  The default implementation simply returns a 
VelocityContext
  +    object with the request and response objects placed inside.
  +  </li>
  +  <li> <code>void setContentType( HttpServletRequest request, HttpServletResponse 
response )</code>
  +    Allows you to examine the request and set the content type yourself, depending 
on the request or
  +    client.  The default implementation sets the content type to be that either 
specified in the 
  +    velocity.properties, if any, or the default, "text/html" if not specified in 
the properties.
  +  </li>
  +  <li> <code>void mergeTemplate( Template template, Context context, 
HttpServletResponse response )</code>
  +    Allows you to produce the output stream.  The VelocityServlet uses a pool of 
very efficient Writer classes,
  +    so this would usually be overridden in special situations.
  +  </li>
  +  <li> <code>void requestCleanup( HttpServletRequest request, HttpServletResponse 
response, Context context )</code>
  +    Allows you to do any cleanup or resource reclamation at the end of the request 
processing.  The default
  +    does nothing.
  +  </li>
  +</ul>
  +
  +For further information, please see the Javadoc <a href='apidocs/index.html'>API 
documentation</a>.
  +</p>
  +
  +
   <strong>Deployment</strong>
   <p>
   When you deploy your Velocity-based servlets, you will certainly want to ensure 
that your properties file is used to configure
  
  
  

Reply via email to