You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Javier <jl...@leyba.com.ar> on 2002/04/19 12:43:22 UTC

Template question

Hi !

I'm new with Velocity and I'm trying to translate an application developed with PHP and FastTemplates to Servlets / Velocity.

After reading Velocity documentation I'm confuse about how to emulate FastTemplate funtionality with Velocity.


Could I put in my template a code like

<tr>
	<td>{ALGO}</td>
</tr>


and assign in my jservlet code a value or another template to ALGO as I did with FastTemplates ?

How ? Where could I found examples about it ?


Thanks in advance

<jl>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by Javier <jl...@leyba.com.ar>.
On 19/04/2002 at 16:50 Emyr James wrote:

>Javier,
>I've just got started with velocity. Initially progress was slow due to
>documentation issues. But the javaworld article by Geir that's linked from
>the main velocity page is excellent. I've now written quite a few
>VelocityServlets and I'm getting great results.
>The article is at
>http://www.javaworld.com/javaworld/jw-12-2001/jw-1228-velocity.html. I
>heartily reccomend following it through from start to finish.


Hi

Thanks, I'm reading it.

<jl>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by Emyr James <em...@OrbisUK.com>.
Javier,
I've just got started with velocity. Initially progress was slow due to documentation issues. But the javaworld article by Geir that's linked from the main velocity page is excellent. I've now written quite a few VelocityServlets and I'm getting great results.
The article is at http://www.javaworld.com/javaworld/jw-12-2001/jw-1228-velocity.html. I heartily reccomend following it through from start to finish.
Cheers,
Emyr

Javier wrote:

> On 19/04/2002 at 11:13 Geir Magnusson Jr. wrote:
>
> >
> >There are two examples included with the package as well.
>
> I don't want to be "ironic". No reply at this point. :)
>
> >
> >The issue may be that Velocity is just a tool that you can use in servlets,
> >and there are many, many ways to use it.  So the examples and docs are
> >there
> >to help get the basic idea across, but in no way is it the definitive
> >answer
> >on how they are to be used.
> >
> >So, apologies if the docs weren't good enough for you.  Will be happy to
> >listen to concrete suggestions on what would have made it better for you.
> >
>
> Well, there to much programmers like me moving from PHP to Java servlets and FastTemplates, Xtemplates or Templates from PHPLib are so popular. I'm sure many of them will give up quickly trying to use velocity if they don't found docs with clear examples about usual PHP/Templates tasks. I think that people that worked developing velocity will be happy if a lot of peopley use their package.
>
> Then why don't write a few clear examples about how to did the same that they did with PHP / FastTemplates with servlets / velocity ?
>
> Also I'll promise if I could understand this fuc..g utility I'll write a  good step-bystep tutorial in english and spanish.....
>
> <jl>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/19/02 11:29 AM, "Javier" <jl...@leyba.com.ar> wrote:

> On 19/04/2002 at 11:13 Geir Magnusson Jr. wrote:
> 
>> 
>> There are two examples included with the package as well.
> 
> I don't want to be "ironic". No reply at this point. :)

I can't imagine that 'irony' would be a word used to describe any comment
you had on this...

> 
>> 
>> The issue may be that Velocity is just a tool that you can use in servlets,
>> and there are many, many ways to use it.  So the examples and docs are
>> there
>> to help get the basic idea across, but in no way is it the definitive
>> answer
>> on how they are to be used.
>> 
>> So, apologies if the docs weren't good enough for you.  Will be happy to
>> listen to concrete suggestions on what would have made it better for you.
>> 
> 
> Well, there to much programmers like me moving from PHP to Java servlets and
> FastTemplates, Xtemplates or Templates from PHPLib are so popular. I'm sure
> many of them will give up quickly trying to use velocity if they don't found
> docs with clear examples about usual PHP/Templates tasks. I think that people
> that worked developing velocity will be happy if a lot of peopley use their
> package.

Well, the issue there is that they aren't really comparable.  PHP includes
everything and the kitchen sink included in the template engine, as I
remember.  (Did a bit of PHP a while ago...)

Velocity is a different beastie philosophically.  The idea is that the basic
template engine contains *nothing*, and you use it to build applications and
frameworks.

PHP to me is a framework because it includes so much.

That is why Christoph pointed you at some of the frameworks that use
velocity - they take care of including tools and managing the templates for
you, just like php does.

Velocity is a lot lower level.

We are trying to make it easier (w/o making a framework) in our
jakarta-velocity-tools project.  There is the beginnings of a servlet
'infrastructure' to be a drop in replacement for JSP, as well as tools and
integration support for the Jakarta Struts framework.
 
> Then why don't write a few clear examples about how to did the same that they
> did with PHP / FastTemplates with servlets / velocity ?

I am not familiar with FastTemplates.

You mean copy a 'well known' example set?  That's not a bad idea...

> 
> Also I'll promise if I could understand this fuc..g utility I'll write a  good
> step-bystep tutorial in english and spanish.....
> 

That would be great.

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting

Maven & Gump are friends


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by Javier <jl...@leyba.com.ar>.
On 19/04/2002 at 11:13 Geir Magnusson Jr. wrote:

>
>There are two examples included with the package as well.

I don't want to be "ironic". No reply at this point. :)

>
>The issue may be that Velocity is just a tool that you can use in servlets,
>and there are many, many ways to use it.  So the examples and docs are
>there
>to help get the basic idea across, but in no way is it the definitive
>answer
>on how they are to be used.
>
>So, apologies if the docs weren't good enough for you.  Will be happy to
>listen to concrete suggestions on what would have made it better for you.
>

Well, there to much programmers like me moving from PHP to Java servlets and FastTemplates, Xtemplates or Templates from PHPLib are so popular. I'm sure many of them will give up quickly trying to use velocity if they don't found docs with clear examples about usual PHP/Templates tasks. I think that people that worked developing velocity will be happy if a lot of peopley use their package. 

Then why don't write a few clear examples about how to did the same that they did with PHP / FastTemplates with servlets / velocity ? 

Also I'll promise if I could understand this fuc..g utility I'll write a  good step-bystep tutorial in english and spanish.....


<jl>





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/19/02 10:52 AM, "Javier" <jl...@leyba.com.ar> wrote:

> On 19/04/2002 at 10:39 Geir Magnusson Jr. wrote:
> 
>>> Yes, I did it. I use to read before ask to not disturb but this part of
>> the
>>> guide is small, poor and with just one so generic example (IMHO).
>>> 
>>> Since I'm trying to use Java I found the big problem it's a poor
>> documentation
>>> existent. I know it's a free world and people doing documentation ara
>> working
>>> for nothing, but.... sometimes documentation looks like to be for experts
>>> instead for newbies.
>> 
>> That's fair.  The assumption is that the reader has some idea about working
>> with servlets...
>> 
> 
> Well, I'm not an expert but I understand servlets.
> 
> Do you found that a documentation with just one example it's a good
> documentation ? It's a joke, right ?

There are two examples included with the package as well.

The issue may be that Velocity is just a tool that you can use in servlets,
and there are many, many ways to use it.  So the examples and docs are there
to help get the basic idea across, but in no way is it the definitive answer
on how they are to be used.

So, apologies if the docs weren't good enough for you.  Will be happy to
listen to concrete suggestions on what would have made it better for you.

> 
> 
> 
>>> 
>>> 
>>>> In short your jservlet code could extend the SampleServlet
>>>> and and implement the handleRequest() method to populate the
>>>> context.
>>>> 
>>>> Some frameworks like ActionServlet, Maverick and WebWork help
>>>> you in a direct start using velocity. See the "Powered by Velocity"
>>>> page in the velocity web site for the links.
>>>> 
>>>> Hope this helps you get going with velocity.
>>> 
>>> Thanks. I prefer not to test/try more tools before really understand
>> velocity.
>>> :)
>>> 
>> 
>> Those tools actually make it easier, as they take care of the mechanics of
>> the servlets, and leave you to application and template design.
>> 
>> 
> 
> 
> Perhaps more tools with a lot of commands and configuration options and poor
> documentation ?

Perhaps - or perhaps not.  I can't tell you for sure.


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
Somebody has to do something, and it's just incredibly pathetic that it has
to be us.  - Jerry Garcia


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by Javier <jl...@leyba.com.ar>.
On 19/04/2002 at 10:34 Barbara Baughman wrote:

>Well, to each his own opinion.  As a newbie, I found the documentation to
>be excellent.  There is always room for improvement in anything, but if
>you don't have anything constructive to say aside from insults, this list
>is not for you.  If you need help with something in particular, this list
>is your best friend.  

Hi Barbara

I've read my previous posts and I didnt found insults. 

Also, I've been constructive and proposed something.

As you could suppose, I disaggre with your opinion about the manual.

>
>Velocity is the easiest software I've ever learned, and a VelocityServlet
>was one of my first servlets (soon after "Hello World").  I needed a lot
>of help understanding how to best write java code, and how to manipulate
>HTTP stuff, but the Velocity part was a piece of cake.  Velocity has a lot
>of dedicated fans, especially on this list!  If you want help, be kind.

Well, I don't know you skill.

As a personal history, I began to use FastTemplates after 5 years to use PHP, then it was so easy for me and I've wrote a tutorial posted on www.phpes.com. Now, I'm 6 months older java programmer. As I said, I'm not an expert and Java/Velocity are by far so different from my experience. May be you come to Velocity as an expert Java programmer and then you found Velocity and it's documentation easy.

But, don't lose the horizont, remember that documentation shall be newbie oriented. An expert will use API reference rather than normal docs.

Newbies will be usually confused when they go to check manuals and found a lot of interesting texts but no or few examples. It's by far more easy to learn following step-by-step examples than try to read all the docs.


<jl>





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


URL loader for jsp

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
Alright, this isn't *technically* a velocity question, but I am not sure
where else to go with this...

I am using the url resource loader and its great.  Thing is, I am coding
an application twice (once with Velocity, once with JSP) just to prove
the best practice.  Sounds just like the three examples in the velocity-view
project doesn't it.  I will use those too but I also want to show my own.

Does anybody know a way to get my application to look for JSP's outside
of the webapp?  Or is that completely impossible?  The more I think about it
it sure sounds not only impossible, but a bit stupid.  Still, to demonstrate
my app it is annoying to have all my Velocity files in a dedicated
"designer only" directory and the JSP pages in the "developer" directory.
It would be nice to have the JSP's next to the VTL pages.

I know I am reaching here.  A simple "no, you can't do that" would suffice.
Thanks.

Charlie


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by Barbara Baughman <ba...@utdallas.edu>.
Well, to each his own opinion.  As a newbie, I found the documentation to
be excellent.  There is always room for improvement in anything, but if
you don't have anything constructive to say aside from insults, this list
is not for you.  If you need help with something in particular, this list
is your best friend.  

Velocity is the easiest software I've ever learned, and a VelocityServlet
was one of my first servlets (soon after "Hello World").  I needed a lot
of help understanding how to best write java code, and how to manipulate
HTTP stuff, but the Velocity part was a piece of cake.  Velocity has a lot
of dedicated fans, especially on this list!  If you want help, be kind.

Barbara Baughman
X2157

On Fri, 19 Apr 2002, Javier wrote:

> On 19/04/2002 at 10:39 Geir Magnusson Jr. wrote:
> 
> >> Yes, I did it. I use to read before ask to not disturb but this part of
> >the
> >> guide is small, poor and with just one so generic example (IMHO).
> >>
> >> Since I'm trying to use Java I found the big problem it's a poor
> >documentation
> >> existent. I know it's a free world and people doing documentation ara
> >working
> >> for nothing, but.... sometimes documentation looks like to be for experts
> >> instead for newbies.
> >
> >That's fair.  The assumption is that the reader has some idea about working
> >with servlets...
> >
> 
> Well, I'm not an expert but I understand servlets.
> 
> Do you found that a documentation with just one example it's a good documentation ? It's a joke, right ?
> 
> 
> 
> >>
> >>
> >>> In short your jservlet code could extend the SampleServlet
> >>> and and implement the handleRequest() method to populate the
> >>> context.
> >>>
> >>> Some frameworks like ActionServlet, Maverick and WebWork help
> >>> you in a direct start using velocity. See the "Powered by Velocity"
> >>> page in the velocity web site for the links.
> >>>
> >>> Hope this helps you get going with velocity.
> >>
> >> Thanks. I prefer not to test/try more tools before really understand
> >velocity.
> >> :)
> >>
> >
> >Those tools actually make it easier, as they take care of the mechanics of
> >the servlets, and leave you to application and template design.
> >
> >
> 
> 
> Perhaps more tools with a lot of commands and configuration options and poor documentation ?
> 
> 
> <jl>
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by Javier <jl...@leyba.com.ar>.
On 19/04/2002 at 10:39 Geir Magnusson Jr. wrote:

>> Yes, I did it. I use to read before ask to not disturb but this part of
>the
>> guide is small, poor and with just one so generic example (IMHO).
>> 
>> Since I'm trying to use Java I found the big problem it's a poor
>documentation
>> existent. I know it's a free world and people doing documentation ara
>working
>> for nothing, but.... sometimes documentation looks like to be for experts
>> instead for newbies.
>
>That's fair.  The assumption is that the reader has some idea about working
>with servlets...
> 

Well, I'm not an expert but I understand servlets.

Do you found that a documentation with just one example it's a good documentation ? It's a joke, right ?



>> 
>> 
>>> In short your jservlet code could extend the SampleServlet
>>> and and implement the handleRequest() method to populate the
>>> context.
>>> 
>>> Some frameworks like ActionServlet, Maverick and WebWork help
>>> you in a direct start using velocity. See the "Powered by Velocity"
>>> page in the velocity web site for the links.
>>> 
>>> Hope this helps you get going with velocity.
>> 
>> Thanks. I prefer not to test/try more tools before really understand
>velocity.
>> :)
>> 
>
>Those tools actually make it easier, as they take care of the mechanics of
>the servlets, and leave you to application and template design.
>
>


Perhaps more tools with a lot of commands and configuration options and poor documentation ?   


<jl>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/19/02 10:36 AM, "Javier" <jl...@leyba.com.ar> wrote:

>>> 
>>> How ? Where could I found examples about it ?
>>> 
>>> Thanks in advance
>> 
>> Please look into the documentation in the
>>    http://jakarta.apache.org/velocity
>> site. The "Developers Guide" has a chapter "Using Velocity In Servlets"
>> that answers your question.
>> 
> 
> 
> Yes, I did it. I use to read before ask to not disturb but this part of the
> guide is small, poor and with just one so generic example (IMHO).
> 
> Since I'm trying to use Java I found the big problem it's a poor documentation
> existent. I know it's a free world and people doing documentation ara working
> for nothing, but.... sometimes documentation looks like to be for experts
> instead for newbies.

That's fair.  The assumption is that the reader has some idea about working
with servlets...
 
> 
> 
>> In short your jservlet code could extend the SampleServlet
>> and and implement the handleRequest() method to populate the
>> context.
>> 
>> Some frameworks like ActionServlet, Maverick and WebWork help
>> you in a direct start using velocity. See the "Powered by Velocity"
>> page in the velocity web site for the links.
>> 
>> Hope this helps you get going with velocity.
> 
> Thanks. I prefer not to test/try more tools before really understand velocity.
> :)
> 

Those tools actually make it easier, as they take care of the mechanics of
the servlets, and leave you to application and template design.


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
The bytecodes are language independent. - Sam Ruby  


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by Javier <jl...@leyba.com.ar>.
On 19/04/2002 at 13:28 Christoph Reck wrote:

>
>Falta el símbolo $ antes de ${ALGO} para ser una referencia válida.
>
>> 
>> and assign in my jservlet code a value or another template to ALGO 
>> as I did with FastTemplates ?
>
>To embed other templates within a velocity template you can use
>#parse("template/resource/name.vtl") or #include("some/file.xyz")

Hi !

Thanks for your reply.

Now I'm more confused. All velocity settings and commands go and work in templates. I'll need to instruct to my visual designers about how to put this code ?

>
>> 
>> How ? Where could I found examples about it ?
>> 
>> Thanks in advance
>
>Please look into the documentation in the 
>    http://jakarta.apache.org/velocity 
>site. The "Developers Guide" has a chapter "Using Velocity In Servlets"
>that answers your question.
>


Yes, I did it. I use to read before ask to not disturb but this part of the guide is small, poor and with just one so generic example (IMHO).

Since I'm trying to use Java I found the big problem it's a poor documentation existent. I know it's a free world and people doing documentation ara working for nothing, but.... sometimes documentation looks like to be for experts instead for newbies.



>In short your jservlet code could extend the SampleServlet
>and and implement the handleRequest() method to populate the
>context. 
>
>Some frameworks like ActionServlet, Maverick and WebWork help
>you in a direct start using velocity. See the "Powered by Velocity" 
>page in the velocity web site for the links.
>
>Hope this helps you get going with velocity.

Thanks. I prefer not to test/try more tools before really understand velocity.   :)


<jl>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by Christoph Reck <Ch...@dlr.de>.
Javier wrote:
> 
> Hi !
> 
> I'm new with Velocity and I'm trying to translate an application 
> developed with PHP and FastTemplates to Servlets / Velocity.
> 
> After reading Velocity documentation I'm confuse about how to emulate 
> FastTemplate funtionality with Velocity.
> 
> Could I put in my template a code like
> 
> <tr>
>         <td>{ALGO}</td>
> </tr>

Falta el símbolo $ antes de ${ALGO} para ser una referencia válida.

> 
> and assign in my jservlet code a value or another template to ALGO 
> as I did with FastTemplates ?

To embed other templates within a velocity template you can use
#parse("template/resource/name.vtl") or #include("some/file.xyz")

> 
> How ? Where could I found examples about it ?
> 
> Thanks in advance

Please look into the documentation in the 
    http://jakarta.apache.org/velocity 
site. The "Developers Guide" has a chapter "Using Velocity In Servlets"
that answers your question.

In short your jservlet code could extend the SampleServlet
and and implement the handleRequest() method to populate the
context. 

Some frameworks like ActionServlet, Maverick and WebWork help
you in a direct start using velocity. See the "Powered by Velocity" 
page in the velocity web site for the links.

Hope this helps you get going with velocity.

Saludos,
:) Christoph Reck

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Template question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 4/19/02 6:43 AM, "Javier" <jl...@leyba.com.ar> wrote:

> 
> Hi !
> 
> I'm new with Velocity and I'm trying to translate an application developed
> with PHP and FastTemplates to Servlets / Velocity.
> 
> After reading Velocity documentation I'm confuse about how to emulate
> FastTemplate funtionality with Velocity.
> 
> 
> Could I put in my template a code like
> 
> <tr>
> <td>{ALGO}</td>
> </tr>
> 
> 
> and assign in my jservlet code a value or another template to ALGO as I did
> with FastTemplates ?
> 
> How ? Where could I found examples about it ?

Velocity has two ways (well, more actually) of including external content.

#parse( arg>)  where <arg> is a literal like 'foo.vm' or a reference like
$mytemplate - it will take the template given as the arg, render it using
the current context, and take the render output and put into the stream at
the point where the #parse() was.

#include(<arg>) will take the input (template or otherwise) and put into the
output stream as-is.  No rendering will be done.  This is like a #include in
the C language.

See the users guide and dev guide, available on the site.

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
The question is : What is a Mahnamahna?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>