You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by David You <dy...@attbi.com> on 2002/07/27 07:55:30 UTC

#foreach vs. Java loops.

HI, there

One engineer in my group is sort of template purist. Though he likes template Engine, he thinks that it should be as simple as possible. He think we should not use
#foreach to do that work, instead, use java loop to loop through another Templates. For example, the parent template only have table header while the children template only have the row, and the servlet do the loop. His argument is that if we use loop in the template it is not much different than use JSP.

I don't know if there has been some debate over this issure here before?
Here are my thoughts about the benefit of using #foreach right on top of head.

 Although using Java loop can do the work, it only complicates things. For sure, your servlets code will be much more complicated.
The templates code seems simpler, It actually create more troubles for the GUI/HTML/Javascript people. Now the GUI people don't know what the page look like without looking at the Java code. For the Table's example, If he need to change the columns, He has to look at the parent template, change it, find the variable for the table row; then look at the servlet code, to get the name of children's template, fix it also. It creates unnecessary relationship of the templates and the servlets, defeats the purpose of seperating Java code from HTML code so the two groups could work more independently.

I would like some feed back, some early debate will be good. Especially from GUI/HTML guys who had experiences with Velocity, what they prefer.


thanks
David




Re: #foreach vs. Java loops.

Posted by Terry Steichen <te...@net-frame.com>.
One way to look at it is to use Java to do whatever is required to get the
data (the list), and then let the template do whatever is required to
present it to the viewer.  From that perspective, #foreach() is a perfectly
legitimate (and necessary) template directive.

Regards,

Terry


----- Original Message -----
From: "David You" <dy...@attbi.com>
To: <ve...@jakarta.apache.org>
Sent: Saturday, July 27, 2002 1:55 AM
Subject: #foreach vs. Java loops.


HI, there

One engineer in my group is sort of template purist. Though he likes
template Engine, he thinks that it should be as simple as possible. He think
we should not use
#foreach to do that work, instead, use java loop to loop through another
Templates. For example, the parent template only have table header while the
children template only have the row, and the servlet do the loop. His
argument is that if we use loop in the template it is not much different
than use JSP.

I don't know if there has been some debate over this issure here before?
Here are my thoughts about the benefit of using #foreach right on top of
head.

 Although using Java loop can do the work, it only complicates things. For
sure, your servlets code will be much more complicated.
The templates code seems simpler, It actually create more troubles for the
GUI/HTML/Javascript people. Now the GUI people don't know what the page look
like without looking at the Java code. For the Table's example, If he need
to change the columns, He has to look at the parent template, change it,
find the variable for the table row; then look at the servlet code, to get
the name of children's template, fix it also. It creates unnecessary
relationship of the templates and the servlets, defeats the purpose of
seperating Java code from HTML code so the two groups could work more
independently.

I would like some feed back, some early debate will be good. Especially from
GUI/HTML guys who had experiences with Velocity, what they prefer.


thanks
David






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