You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Rodrigo Reyes <ro...@instaservi.com> on 2002/11/21 18:43:57 UTC

Using #stop

Hi
    Is there any way to stop the template execution at any point? I tried
using #stop, but it gives me an error. Here is the code I used:

#foreach($root in $roots)
 #if($queryexecuter.isEmptyElement($root))
  #stop
 #end
#end

    What am I doing wrong? Thanx

Rodrigo



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


Re: Using #stop

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On Thursday, November 21, 2002, at 01:14 PM, Nathan Bubna wrote:

> Roderigo said:
>> Hi
>>     Is there any way to stop the template execution at any point? I 
>> tried
>> using #stop, but it gives me an error. Here is the code I used:
>>
>> #foreach($root in $roots)
>>  #if($queryexecuter.isEmptyElement($root))
>>   #stop
>>  #end
>> #end
>>
>>     What am I doing wrong? Thanx
>
> afaik, the #stop directive does not stop template *rendering,* rather, 
> it
> stops template *parsing.*  imho, a good rule of thumb when it comes to 
> #stop
> is to never use it.
>
> frankly, i'm of the opinion #stop should be done away with.
>

I agree.  I never liked stop - and I don't think anyone uses it.

Any disagreement?

-- 
Geir Magnusson Jr                                   203-355-2219(w)
Adeptra, Inc.                                       203-247-1713(m)
geirm@adeptra.com


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


Re: Using #stop

Posted by Nathan Bubna <na...@esha.com>.
Roderigo said:
> Hi
>     Is there any way to stop the template execution at any point? I tried
> using #stop, but it gives me an error. Here is the code I used:
>
> #foreach($root in $roots)
>  #if($queryexecuter.isEmptyElement($root))
>   #stop
>  #end
> #end
>
>     What am I doing wrong? Thanx

afaik, the #stop directive does not stop template *rendering,* rather, it
stops template *parsing.*  imho, a good rule of thumb when it comes to #stop
is to never use it.

frankly, i'm of the opinion #stop should be done away with.

Nathan Bubna
nathan@esha.com


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


Re: Velocity powered Websites - request

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Friday, November 22, 2002, at 11:23 AM, Matthew Walker wrote:

> Apologies for noise contribution
>
> The document, http://jakarta.apache.org/velocity/powered.html, 
> explains that I should e-mail this list to request my site to be added 
> to the 'Velocity Powered Websites' section of 
> jakarta,apache.org/velocity. With that said, data is below:
>
> URL: tbjug.org
> Description: Online presence for the Tampa Bay Java User Group
> Created By: OAS (http://www.oasportal.com/)
>

Done

> Also, (and more to the recipients out there), I would like to discuss 
> this graphic, http://tbjug.org/images/velocity_diagram.png, which 
> depicts a (high level) design of the site and how velocity is 
> involved. This is my first velocity implementation and I'm wondering 
> if any experienced archs out there see this as absurd, (or not).
> For clarification, the servlet inheritance allows me to easily append 
> logic to the site by simply extending TBVelocityServlet. The 
> descendants are only tasked with going about their business and adding 
> stuff to the Context and can be blissfully ignorant of which template 
> to load. I feel comfortable with this from an MVC perspective since my 
> servlets are all Model. This is the way it should be, and I'm 
> beginning to forget what life was like before velocity. Anyway, I'm 
> very eager to see if other people have used similar designs. Of 
> course, using tbjug.org and keeping an eye on one's URI should support 
> the graphic's flow of things if further clarification is needed.

Looking at the graphic now, that seems good.  I tend to do things the 
same way.  I have a base servlet that deals with velocity stuff, and 
just extend it for the specific uses.  I use a cheap little 'action 
model' using reflection, and while admittedly cheesy, it does get done 
what I want to get done very simply.

geir

>
> -Matt
>
>
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geirm@optonline.net


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Velocity powered Websites - request

Posted by Matthew Walker <mw...@electronicdatainc.com>.
Apologies for noise contribution

The document, http://jakarta.apache.org/velocity/powered.html, explains 
that I should e-mail this list to request my site to be added to the 
'Velocity Powered Websites' section of jakarta,apache.org/velocity. With 
that said, data is below:

URL: tbjug.org
Description: Online presence for the Tampa Bay Java User Group
Created By: OAS (http://www.oasportal.com/)

Also, (and more to the recipients out there), I would like to discuss 
this graphic, http://tbjug.org/images/velocity_diagram.png, which 
depicts a (high level) design of the site and how velocity is involved. 
This is my first velocity implementation and I'm wondering if any 
experienced archs out there see this as absurd, (or not).
For clarification, the servlet inheritance allows me to easily append 
logic to the site by simply extending TBVelocityServlet. The descendants 
are only tasked with going about their business and adding stuff to the 
Context and can be blissfully ignorant of which template to load. I feel 
comfortable with this from an MVC perspective since my servlets are all 
Model. This is the way it should be, and I'm beginning to forget what 
life was like before velocity. Anyway, I'm very eager to see if other 
people have used similar designs. Of course, using tbjug.org and keeping 
an eye on one's URI should support the graphic's flow of things if 
further clarification is needed.

-Matt


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


RE: Using #stop

Posted by Peter Romianowski <me...@gmx.de>.
  Yes, I agree. The current semantics of #stop are quite useless.
The *expected* meaning (by many users) would be great: Stop *rendering*
the template. What about giving #stop the meaning everyone intends?

> -----Original Message-----
> From: Rodrigo Reyes [mailto:rodrigo@instaservi.com] 
> Sent: Thursday, November 21, 2002 9:34 PM
> To: Velocity Users List
> Subject: Re: Using #stop
> 
> 
> Thanx Geir
> Still, I think there are sometimes when stopping is not that 
> bad. In this specific case (for example) what I was trying to 
> avoid is having a huge #if ... #else... #end. Why? Because 
> (at least in velocity) it is harder to debug or mantain. You 
> have to use tabs in order to see where your #if's #end, and 
> that makes the final HTML code even more wrecked. Any other 
> workaround?
> 
> Rodrigo
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:velocity-user-> unsubscribe@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: Using #stop

Posted by Rodrigo Reyes <ro...@instaservi.com>.
Thanx Geir
Still, I think there are sometimes when stopping is not that bad. In this
specific case (for example) what I was trying to avoid is having a huge #if
... #else... #end. Why? Because (at least in velocity) it is harder to debug
or mantain. You have to use tabs in order to see where your #if's #end, and
that makes the final HTML code even more wrecked. Any other workaround?

Rodrigo



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


Re: Using #stop

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On Thursday, November 21, 2002, at 12:43 PM, Rodrigo Reyes wrote:

> Hi
>     Is there any way to stop the template execution at any point? I 
> tried
> using #stop, but it gives me an error. Here is the code I used:
>
> #foreach($root in $roots)
>  #if($queryexecuter.isEmptyElement($root))
>   #stop
>  #end
> #end
>
>     What am I doing wrong? Thanx
>

Nathan already answered about #stop, but I'll suggest another solution.

If you want to stop rendering, one suggestion is to use a tool with a 
method  that will throw an exception.

You can catch it during rendering

   try
   {
        template.merge(....);
   }
   catch(StopRenderingTemplateException srte)
   {
       ...
   }

-- 
Geir Magnusson Jr                                   203-355-2219(w)
Adeptra, Inc.                                       203-247-1713(m)
geirm@adeptra.com


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