I'm rather new to velocity, but find it would save me a
 ton of work.  I've tryied it using some templates to generate stored
 procedures and found it quite easy.  Now I would like to try and us it in
an
 application with rather small, in-memory templates.  The problem is, I can
not
 seem to get this to work.  Here is a simple example:
 
  
 
 What I'm trying to do, is pass the template as the name, then create a new
 resource loader to just return the name as a byte stream.
 
 Obviously, this is not correct.
 
  
 
 
 String c ="create table $schemaName.$tablename (  "
 + " #foreach ($dbColumn in $columnList) "
 + "    $dbColumn.columnName $dbColumn.SQLDef,  "
 + " #end "
 + " purge_date datestamp )";
 
 Velocity.init(); // don't hurt
 Template temp =new Template();
 
 StringResourceLoader sl = new StringResourceLoader();
 StringWriter sw = new StringWriter();
 VelocityContext context = new VelocityContext();
 context.put("schemaName",schemaName);
 context.put("tablename",getTbName());
 context.put("columnList",v);
 temp.setResourceLoader(sl);
 temp.setName(c);
 temp.process();
 temp.merge(context,sw);
 
 // try this
 
 System.out.println(sw.toString());
 
  
 
  
 
 My String Resource Loader looks
 
 public InputStream getResourceStream(String arg0)
       throws ResourceNotFoundException
    {
      
       ByteArrayInputStream is = new ByteArrayInputStream(arg0.getBytes());
       return is;
      
    }
 

 thanks
 

Ed Ross
TechRx
530 Lindbergh Drive
Coraoplis, PA 15108
(412)474-1106

This E-mail message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information.  Any unauthorized review,
use, disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply E-mail, and destroy all copies
of the original message.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to