You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Ed Bras <po...@hotmail.com> on 2000/12/29 11:14:13 UTC

Difference

Hellu,

I am just starting to use velocity and have some question. Please help me 
with these:
- When should someone choose velocity or webmacro (what is the difference ?
- Where can I find some examples ? I am having problems of setting the 
template/log path. How can I do that ? Every time he looks in the wrong dir 
for the template and puts the log file, there where the application server 
(Orion) is started ?
I tried to use the org.apache.velocity.texen.ant.TexenTaks class to change 
the template path, but everytime it says "cannot access 
org.apache.tools.ant.Task
file org/apache/tools/ant/Task.class not found" when I use the 
setTemplatePath method!! Which isn't that weird as I can find this package 
in the api doc.

Regards,
Ed Bras

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


Re: Difference

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Ed Bras wrote:
> 
> Hellu,
> 
> I am just starting to use velocity and have some question. Please help me
> with these:
> - When should someone choose velocity or webmacro (what is the difference ?

That is somewhat of a personal judgment, I believe.  The best way if you
don't want to just take my word for it to just use Velocity ;-> is to
try them both and see.  They are very, very similar in both template
language as well as Java-side coding patterns (I mean, Vel was modeled
after WM) that you really won't waste much time. 

WebMacro (WM) was first, and Velocity owes a debt of gratitude to WM for
the early work in this area.  WM has been around longer, and therefore
is used in many places, and that fact is important to some people.  I
believe that most of the Velocity developers (including myself) are WM
users, but most of us (including myself) are porting our projects over
to Velocity as fast as we can. ("Eat your own dogfood")

A primary differentiator, in my opinion, is the Velocimacro (VM)
feature, a mechanism which allows the designer to create parameterized
'macros' of template code, and reuse them throughout an application. It
is a tremendously powerful and convenient feature.  For real examples of
VM use, look at the Anakia example (part of the Velocity download, in
the examples directory) as well as Torque, found under
http://java.apache.org/turbine/index.html  (or http://java.apache.org
and look for turbine... they like frames there for some reason :)

I believe that other niceities of Velocity include (and note that this
is only *my* personal opinion, and not in any way meant to be a
comparison / criticism of WM ) :

- the template language is very clean and the parser is very good, and
we are very active about finding and removing parser bugs
- resource handling for #parse() and #include() is 'normalized', so you
can keep your content tree in one place, and not have to worry about
absolute paths to things
- we have (so far) stuck to the original philosophy of 'Keep It Simple,
Stupid' and have done a decent job of keeping facilities and features
best left to applications and frameworks out of Velocity.  This means
that (I believe) our core code is simple and easy to maintain over the
long run.
- Velocity is an Apache Jakarta subprobject, and released under the APL

> - Where can I find some examples ? I am having problems of setting the
> template/log path. How can I do that ? Every time he looks in the wrong dir
> for the template and puts the log file, there where the application server
> (Orion) is started ?

There are plenty of examples in the project tree.  The best places to
look for examples of templates is our automated test bed templates : 
test/templates/*.vm   Also the examples directory has a simple servlet
example, a simple app example (Example.java), and then there is Anakia,
a powerful demonstration of how to use Velocimacros, and forumdemo, a
working forum application.

You can set the template and log path with the following :

runtime.log = <path>/velocity.log
resource.loader.1.resource.path = <template path>

put those into a velocity.properties file, and somehow convince Orion to
feed that to the servlet. (I am not familiar with Orion....)  I use
tomcat, and put it in the web.xml (and I am never sure if I am doing the
right thing :)

Let me know if you are still having problems.  We'll work it out :)

> I tried to use the org.apache.velocity.texen.ant.TexenTaks class to change
> the template path, but everytime it says "cannot access
> org.apache.tools.ant.Task
> file org/apache/tools/ant/Task.class not found" when I use the
> setTemplatePath method!! Which isn't that weird as I can find this package
> in the api doc.

I am not very familiar with Texen, but unless your intent is solely
using Texen, you are barking up the wrong tree.  Texen is a companion
toolset provided with Velocity, and not required for general Velocity
use.

geir

> 
> Regards,
> Ed Bras
> 
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity