You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by piero de salvia <pi...@yahoo.com> on 2001/07/19 20:44:47 UTC

Instantiable Velocity Engine

Hello everybody,

I am trying the instantiable VE in the Velocity
servlet ( a modified versione of mine ) and, although
I can do this : (vEngine = new VelocityEngine())

public Template getTemplate( String name )
        throws ResourceNotFoundException,             
ParseErrorException, Exception
{
return vEngine.getTemplate(name);
}

I cannot do this:

protected void mergeTemplate( Template template.... {
...
vEngine.mergeTemplate(template, context, vw);
....
}

In the example app first arg is a String, but the
servlet need to do getTemplate and Merge in two
steps...

I tried to look into the source but it won't open, it
seems corrupted (I am on Window$ - cannot do
differently right now)

piero de salvia

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: Any idea why this doesn't work

Posted by Uday Kumar <ud...@eself.com>.
:) :) :)   u definitely need a break... 

-Uday


----- Original Message ----- 
From: "Dave Cramer" <Da...@micro-automation.net>
To: <ve...@jakarta.apache.org>
Sent: Thursday, July 19, 2001 7:09 PM
Subject: RE: Any idea why this doesn't work


> Thanks, now I feel stupid, time for a break
> 
> --dc--
> 
> -----Original Message-----
> From: gmj@mta4.srv.hcvlny.cv.net [mailto:gmj@mta4.srv.hcvlny.cv.net] On
> Behalf Of Geir Magnusson Jr.
> Sent: July 19, 2001 10:06 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Any idea why this doesn't work
> 
> 
> #elif isn't a directive
> 
> try
> 
> #elseif
> 
> :)
> 
> geir
> 
> 
> Dave Cramer wrote:
> > 
> > The following works
> > 
> >         #if ($Store == 'Grocery')
> > 
> >           <b>$Catalog.Render()</b>
> > 
> >           <font face='Arial, Helvetica, sans-serif' size='2' 
> > color='#000000'><b>
> >             <b>
> >                 <a 
> > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> >                         Movie Rental
> >                 </a>
> >             </b>
> >               </font>
> >         #end
> >         #if ($Store == 'Rental')
> >           #foreach ($store in $OpenedStores)
> >                       <b><a 
> > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Gr
> > oc
> > ery">
> >             <font face="Arial, Helvetica, sans-serif" size="2"
> > >$store.Name</font></a><br>
> >           #end
> >           <b>$Catalog.Render()</b>
> >           #end
> > 
> > But this doesn't
> > 
> >         #if ($Store == 'Grocery')
> > 
> >           <b>$Catalog.Render()</b>
> > 
> >           <font face='Arial, Helvetica, sans-serif' size='2' 
> > color='#000000'><b>
> >             <b>
> >                 <a 
> > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> >                         Movie Rental
> >                 </a>
> >             </b>
> >               </font>
> > 
> >         #elif ($Store == 'Rental')
> >           #foreach ($store in $OpenedStores)
> >                       <b><a 
> > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Gr
> > oc
> > ery">
> >             <font face="Arial, Helvetica, sans-serif" size="2"
> > >$store.Name</font></a><br>
> >           #end
> >           <b>$Catalog.Render()</b>
> >           #end
> > 
> > The difference is the #end #if was changed to #elif. When the template
> 
> > is displayed I see #elif (xxx == 'Grocery') on the page
> > 
> > TIA,
> > 
> > Dave
> 
> -- 
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> You have a genius for suggesting things I've come a cropper with!
> 
> 
> 


RE: Any idea why this doesn't work

Posted by Dave Cramer <Da...@micro-automation.net>.
Thanks, now I feel stupid, time for a break

--dc--

-----Original Message-----
From: gmj@mta4.srv.hcvlny.cv.net [mailto:gmj@mta4.srv.hcvlny.cv.net] On
Behalf Of Geir Magnusson Jr.
Sent: July 19, 2001 10:06 PM
To: velocity-user@jakarta.apache.org
Subject: Re: Any idea why this doesn't work


#elif isn't a directive

try

#elseif

:)

geir


Dave Cramer wrote:
> 
> The following works
> 
>         #if ($Store == 'Grocery')
> 
>           <b>$Catalog.Render()</b>
> 
>           <font face='Arial, Helvetica, sans-serif' size='2' 
> color='#000000'><b>
>             <b>
>                 <a 
> href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
>                         Movie Rental
>                 </a>
>             </b>
>               </font>
>         #end
>         #if ($Store == 'Rental')
>           #foreach ($store in $OpenedStores)
>                       <b><a 
> href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Gr
> oc
> ery">
>             <font face="Arial, Helvetica, sans-serif" size="2"
> >$store.Name</font></a><br>
>           #end
>           <b>$Catalog.Render()</b>
>           #end
> 
> But this doesn't
> 
>         #if ($Store == 'Grocery')
> 
>           <b>$Catalog.Render()</b>
> 
>           <font face='Arial, Helvetica, sans-serif' size='2' 
> color='#000000'><b>
>             <b>
>                 <a 
> href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
>                         Movie Rental
>                 </a>
>             </b>
>               </font>
> 
>         #elif ($Store == 'Rental')
>           #foreach ($store in $OpenedStores)
>                       <b><a 
> href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Gr
> oc
> ery">
>             <font face="Arial, Helvetica, sans-serif" size="2"
> >$store.Name</font></a><br>
>           #end
>           <b>$Catalog.Render()</b>
>           #end
> 
> The difference is the #end #if was changed to #elif. When the template

> is displayed I see #elif (xxx == 'Grocery') on the page
> 
> TIA,
> 
> Dave

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!



Re: Any idea why this doesn't work

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
#elif isn't a directive

try

#elseif

:)

geir


Dave Cramer wrote:
> 
> The following works
> 
>         #if ($Store == 'Grocery')
> 
>           <b>$Catalog.Render()</b>
> 
>           <font face='Arial, Helvetica, sans-serif' size='2'
> color='#000000'><b>
>             <b>
>                 <a
> href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
>                         Movie Rental
>                 </a>
>             </b>
>               </font>
>         #end
>         #if ($Store == 'Rental')
>           #foreach ($store in $OpenedStores)
>                       <b><a
> href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Groc
> ery">
>             <font face="Arial, Helvetica, sans-serif" size="2"
> >$store.Name</font></a><br>
>           #end
>           <b>$Catalog.Render()</b>
>           #end
> 
> But this doesn't
> 
>         #if ($Store == 'Grocery')
> 
>           <b>$Catalog.Render()</b>
> 
>           <font face='Arial, Helvetica, sans-serif' size='2'
> color='#000000'><b>
>             <b>
>                 <a
> href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
>                         Movie Rental
>                 </a>
>             </b>
>               </font>
> 
>         #elif ($Store == 'Rental')
>           #foreach ($store in $OpenedStores)
>                       <b><a
> href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Groc
> ery">
>             <font face="Arial, Helvetica, sans-serif" size="2"
> >$store.Name</font></a><br>
>           #end
>           <b>$Catalog.Render()</b>
>           #end
> 
> The difference is the #end #if was changed to #elif. When the template
> is displayed I see #elif (xxx == 'Grocery') on the page
> 
> TIA,
> 
> Dave

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

RE: Any idea why this doesn't work

Posted by Tal Dayan <ta...@zapta.com>.
> 'Schmoo' is my pet word (that I am working hard to get into the Velocity
> vernacular :) for anything in a template that isn't a valid directive or
> a reference.  Velocity must ignore the schmoo and render as is.

Here is a free P.R. advice, add it to the users manuals and make sure
it apears at least 20 times ;-)

>
> > Anyway, it would be nice to report an error in this case. I Hope this
> > is what you had in mind ;-)
>
> It's not an error :)  This is what made the Velocity parser so
> interesting - unlike any other language I can think of, it must find the
> grammatical structure embedded in a sea of stuff that it has to ignore,
> even if that stuff is 'similar'.  HTML, I guess, is sort of this way,
> except it won't render things like <foo>, where velocity will render
> #elsif as '#elsif'

Just for the record, I refered to the C preprocessor which has a similar
task
as Velocity and not the C language itself. Anyway, the argument that
declaring this as an error will flag also things like '#aabbcc' color
specification
make perfect sense to me. This may explain why the C language does not have
a '#' operator.

Thanks for a great product.

Tal

>
> geir
>
> --
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> You have a genius for suggesting things I've come a cropper with!
>


Re: Any idea why this doesn't work

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Tal Dayan wrote:
> 
> > >
> > > Just curious, did you get an exception or an error message or did the
> > > execution (merging) of the template went silently about the error ?
> >
> > That would have went silently...  it was schmoo...
> 
> 
> At the risk of sounding dense, I am not sure what 'schmoo...' means.
> 

'Schmoo' is my pet word (that I am working hard to get into the Velocity
vernacular :) for anything in a template that isn't a valid directive or
a reference.  Velocity must ignore the schmoo and render as is.

> Anyway, it would be nice to report an error in this case. I Hope this
> is what you had in mind ;-)

It's not an error :)  This is what made the Velocity parser so
interesting - unlike any other language I can think of, it must find the
grammatical structure embedded in a sea of stuff that it has to ignore,
even if that stuff is 'similar'.  HTML, I guess, is sort of this way,
except it won't render things like <foo>, where velocity will render
#elsif as '#elsif'

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

RE: Any idea why this doesn't work

Posted by Tal Dayan <ta...@zapta.com>.
> > 
> > Just curious, did you get an exception or an error message or did the
> > execution (merging) of the template went silently about the error ?
> 
> That would have went silently...  it was schmoo...

                               
At the risk of sounding dense, I am not sure what 'schmoo...' means.

Anyway, it would be nice to report an error in this case. I Hope this
is what you had in mind ;-)

Tal




Re: Any idea why this doesn't work

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Tal Dayan wrote:
> 
> Just curious, did you get an exception or an error message or did the
> execution (merging) of the template went silently about the error ?

That would have went silently...  it was schmoo...

> 
> Tal
> 
> > -----Original Message-----
> > From: Dave Cramer [mailto:Dave@micro-automation.net]
> > Sent: Thursday, July 19, 2001 6:56 PM
> > To: velocity-user@jakarta.apache.org
> > Subject: Any idea why this doesn't work
> >
> >
> > The following works
> >
> >
> >       #if ($Store == 'Grocery')
> >
> >           <b>$Catalog.Render()</b>
> >
> >           <font face='Arial, Helvetica, sans-serif' size='2'
> > color='#000000'><b>
> >             <b>
> >               <a
> > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> >                       Movie Rental
> >               </a>
> >             </b>
> >             </font>
> >         #end
> >         #if ($Store == 'Rental')
> >           #foreach ($store in $OpenedStores)
> >                     <b><a
> > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Groc
> > ery">
> >             <font face="Arial, Helvetica, sans-serif" size="2"
> > >$store.Name</font></a><br>
> >           #end
> >           <b>$Catalog.Render()</b>
> >         #end
> >
> > But this doesn't
> >
> >       #if ($Store == 'Grocery')
> >
> >           <b>$Catalog.Render()</b>
> >
> >           <font face='Arial, Helvetica, sans-serif' size='2'
> > color='#000000'><b>
> >             <b>
> >               <a
> > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> >                       Movie Rental
> >               </a>
> >             </b>
> >             </font>
> >
> >         #elif ($Store == 'Rental')
> >           #foreach ($store in $OpenedStores)
> >                     <b><a
> > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Groc
> > ery">
> >             <font face="Arial, Helvetica, sans-serif" size="2"
> > >$store.Name</font></a><br>
> >           #end
> >           <b>$Catalog.Render()</b>
> >         #end
> >
> > The difference is the #end #if was changed to #elif. When the template
> > is displayed I see #elif (xxx == 'Grocery') on the page
> >
> > TIA,
> >
> > Dave
> >
> >

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: Any idea why this doesn't work

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Tal Dayan wrote:
> 
> I am not sure about that. '#elif' looks like an invalid directive, so
> Velocity
> could catch it (since there is a valid escape sequence to generate
> '#elif' is needed).
> 
> I think this is the behavior of standard C/CPP preprocessors, they give an
> error if you try to use a invalid directive.

Of course, but C is a much stricter language than Velocity's VTL.  With
C, everything in an input stream must be syntactically correct.  There
is no 'freeform stuff' in a C program.  In VTL, it can be mostly
freeform stuff (or even none...).

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: #parse doesn't work with evaluate()

Posted by Dan Finkelstein <da...@emind.com>.
This new jar worked great !! We are very, very happy campers !!

Thanks Geir,

Dan

PS -- The reason that Piero can't read the 
whiteboard/geir/velocity_src_20010722.tgz file is that it wasn't added with 
the "-kb" flag -- for binary files.



At 10:40 PM 7/22/01 -0400, you wrote:
>Dan Finkelstein wrote:
> >
> > Here's an odd one.   It happens in the 1.2 dev jar, not in Velocity
> > 1.0.  #parse fails when evaluate() is used but works ok with
> > getTemplate()/merge().
>
>[SNIP]
>
>This is now fixed in both CVS HEAD as well as the proposed version in
>/whiteboard/geir.
>
>I am uploading a new source tree for the 'single instance' code as well
>as a jar, so anyone interested in the new separate instance stuff should
>use the whiteboard version - it is up to date with CVS HEAD, and
>everyone else should give the new jar from whiteboard a try in their
>existing apps to make sure that the latest changes don't do any harm.
>It shouldn't :) The more testers the merrier.
>
>geir
>
>--
>Geir Magnusson Jr.                           geirm@optonline.net
>System and Software Consulting
>Developing for the web?  See http://jakarta.apache.org/velocity/
>Be well, do good work, and keep in touch.

Dan Finkelstein
Senior Architect, Instructional Tools & Technology
eMind LLC
Northern California Annex
1250 Addison St, Suite #210
Berkeley, CA 94702-1700
Tel: (510) 486-2740
Fax: (510)486-2843

Visit us at <http://www.emind.com/>

This email 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 email and destroy all copies
of the original message.


Re: #parse doesn't work with evaluate()

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
The reason why this doesn't work is because I have been a distracted
dunderhead lately and I didn't fix it when I fixed #inculde() - I will
have the fix in tonight...  I know what it is...

geir


Dan Finkelstein wrote:
> 
> Here's an odd one.   It happens in the 1.2 dev jar, not in Velocity
> 1.0.  #parse fails when evaluate() is used but works ok with
> getTemplate()/merge().
> 
> We have templates that begin something like this line:
> 
>         #parse ("global.vm")
> 
> It has a bunch of #set-s.  Typical lines might be something like
> 
>         #set ($jFontFace = 'Arial, Helvetica, Tahoma, Verdana, sans-serif')
>         #set ($style_author = "font-family: $jFontFace; font-size: 12pt; color:
> #CCCCCC")
> 
> What we really want is for this file to be read in before every template is
> processed, sort of like a global define.  Now, when we run our processor,
> velocity.log contains this error:
> 
>         Fri Jul 20 15:16:36 PDT 2001  [error] #parse : cannot find global.vm template!
> 
> Weird.  Now, if I change the line to
> 
>         #include ("global.vm")
> 
> then it finds the file just fine.  Strange, huh?
> 
> I included some small files so you can replicate it easily....
> 
> Thanks again,
> Dan
> 
> 
> 
>   ------------------------------------------------------------------------
> 
>    test.vmName: test.vm
>           Type: Plain Text (text/plain)
> 
>    Example.javaName: Example.java
>                Type: Plain Text (text/plain)
> 
>    example.vmName: example.vm
>              Type: Plain Text (text/plain)
> 
>   ------------------------------------------------------------------------
> Dan Finkelstein
> Senior Architect, Instructional Tools & Technology
> eMind LLC
> Northern California Annex
> 1250 Addison St, Suite #210
> Berkeley, CA 94702-1700
> Tel: (510) 486-2740
> Fax: (510)486-2843
> 
> Visit us at <http://www.emind.com/>
> 
> This email 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 email and destroy all copies
> of the original message.

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: #parse doesn't work with evaluate()

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Dan Finkelstein wrote:
> 
> Here's an odd one.   It happens in the 1.2 dev jar, not in Velocity
> 1.0.  #parse fails when evaluate() is used but works ok with
> getTemplate()/merge().

[SNIP]

This is now fixed in both CVS HEAD as well as the proposed version in
/whiteboard/geir.

I am uploading a new source tree for the 'single instance' code as well
as a jar, so anyone interested in the new separate instance stuff should
use the whiteboard version - it is up to date with CVS HEAD, and
everyone else should give the new jar from whiteboard a try in their
existing apps to make sure that the latest changes don't do any harm. 
It shouldn't :) The more testers the merrier.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
Be well, do good work, and keep in touch.

Re: #parse doesn't work with evaluate()

Posted by Jon Stevens <jo...@latchkey.com>.
on 7/20/01 4:04 PM, "Dan Finkelstein" <da...@emind.com> wrote:

> Here's an odd one.   It happens in the 1.2 dev jar, not in Velocity
> 1.0.  #parse fails when evaluate() is used but works ok with
> getTemplate()/merge().
> 
> We have templates that begin something like this line:
> 
> #parse ("global.vm")
> 
> It has a bunch of #set-s.  Typical lines might be something like
> 
> #set ($jFontFace = 'Arial, Helvetica, Tahoma, Verdana, sans-serif')
> #set ($style_author = "font-family: $jFontFace; font-size: 12pt; color:
> #CCCCCC")
> 
> What we really want is for this file to be read in before every template is
> processed, sort of like a global define.  Now, when we run our processor,
> velocity.log contains this error:
> 
> Fri Jul 20 15:16:36 PDT 2001  [error] #parse : cannot find global.vm template!
> 
> Weird.  Now, if I change the line to
> 
> #include ("global.vm")
> 
> then it finds the file just fine.  Strange, huh?
> 
> I included some small files so you can replicate it easily....
> 
> Thanks again,
> Dan

I would not say that is strange, more a lack of clarity...

I bet what is happening is that #parse is failing to properly parse the file
and therefore, it isn't available to the resource loader. #include doesn't
parse the file.

Now, the question is...why aren't you using #parse to load the file and not
the velocimacro.library= property?

-jon


#parse doesn't work with evaluate()

Posted by Dan Finkelstein <da...@emind.com>.
Here's an odd one.   It happens in the 1.2 dev jar, not in Velocity 
1.0.  #parse fails when evaluate() is used but works ok with 
getTemplate()/merge().

We have templates that begin something like this line:

	#parse ("global.vm")

It has a bunch of #set-s.  Typical lines might be something like

	#set ($jFontFace = 'Arial, Helvetica, Tahoma, Verdana, sans-serif')
	#set ($style_author = "font-family: $jFontFace; font-size: 12pt; color: 
#CCCCCC")

What we really want is for this file to be read in before every template is 
processed, sort of like a global define.  Now, when we run our processor, 
velocity.log contains this error:

	Fri Jul 20 15:16:36 PDT 2001  [error] #parse : cannot find global.vm template!

Weird.  Now, if I change the line to

	#include ("global.vm")

then it finds the file just fine.  Strange, huh?

I included some small files so you can replicate it easily....

Thanks again,
Dan

	

Re: VelocityEngine

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
piero de salvia wrote:
> 
> Hi guys,
> 
> I'm having a bit of trouble with a file in the CVS,
> namely whiteboard/geir/velocity_src_20010715.tgz , my
> system says it's corrupted.

Hm.

> 
> since I have been waiting to try this stuff VERY VERY
> EAGERLY, will somebody give me a list of method
> signatures in VelocityEngine ?
> 

I will upload a new src tonight, as I fixed (I hope) the #parse()/Eval()
problem reported by Dan, and since Dan is using the new single instance
(I think), I want that to be there for him.

I will also put the fix into CVS HEAD.

Anyone else, give the new VelocityEngine version a try - it's the same
as CVS HEAD except for the [widespread] changes to make single instance
possible.  These changes aren't really functional ( I did fix a small
bug or two...)  I don't want to continue too long with this not checked
in, as I have to do double work each time there is a fix (see above :),
so we should decide after a few people try it.

geir

> 
> and remember guys, we aren't Velocity users by
> chance...we rule!
> 
> piero de salvia
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
Be well, do good work, and keep in touch.

VelocityEngine

Posted by piero de salvia <pi...@yahoo.com>.
Hi guys,

I'm having a bit of trouble with a file in the CVS,
namely whiteboard/geir/velocity_src_20010715.tgz , my
system says it's corrupted. 

since I have been waiting to try this stuff VERY VERY
EAGERLY, will somebody give me a list of method
signatures in VelocityEngine ?

thanks

and remember guys, we aren't Velocity users by
chance...we rule!

piero de salvia

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

RE: Any idea why this doesn't work

Posted by Tal Dayan <ta...@zapta.com>.
If so, I take back my suggestion to report an error for invalid 
'#' directives. After all, it is just a schmoo.

Tal

> -----Original Message-----
> From: Jeremy Leader [mailto:jleader@alumni.caltech.edu]
> Sent: Friday, July 20, 2001 9:20 AM
> To: velocity-user@jakarta.apache.org
> Subject: RE: Any idea why this doesn't work
> 
> 
> At 09:11 AM 7/20/01 , Tal Dayan wrote:
> >I see, yes, this make sense.
> >
> >BTW, does the '#' directives such as #if need to be in the begining
> >of the line (after possibly a white space) or can they be anywhere
> >in the line ?
> >
> >Tal
> 
> I believe VTL directives are recognized anywhere in the line.
> At least, I've done things like:
> 
> <option name="foo" #if($a)selected#end>
> 
> and they worked.
> 
> Jeremy
> 
> 

RE: Any idea why this doesn't work

Posted by Jeremy Leader <jl...@alumni.caltech.edu>.
At 09:11 AM 7/20/01 , Tal Dayan wrote:
>I see, yes, this make sense.
>
>BTW, does the '#' directives such as #if need to be in the begining
>of the line (after possibly a white space) or can they be anywhere
>in the line ?
>
>Tal

I believe VTL directives are recognized anywhere in the line.
At least, I've done things like:

<option name="foo" #if($a)selected#end>

and they worked.

Jeremy


RE: Any idea why this doesn't work

Posted by Tal Dayan <ta...@zapta.com>.
I see, yes, this make sense.

BTW, does the '#' directives such as #if need to be in the begining
of the line (after possibly a white space) or can they be anywhere
in the line ?

Tal

> -----Original Message-----
> From: Dave Cramer [mailto:Dave@micro-automation.net]
> Sent: Friday, July 20, 2001 2:34 AM
> To: velocity-user@jakarta.apache.org
> Subject: RE: Any idea why this doesn't work
> 
> 
> Tal,
> 
> That would mean that everywhere there was an # we would get an error.
> This may be useful, but would generate a lot of error messages (colour
> definitions for example) . 
> 
> Dave
> 
> -----Original Message-----
> From: Tal Dayan [mailto:tal@zapta.com] 
> Sent: July 20, 2001 5:31 AM
> To: Dave@micro-automation.net; velocity-user@jakarta.apache.org
> Subject: RE: Any idea why this doesn't work
> 
> 
> I am not sure about that. '#elif' looks like an invalid directive, so
> Velocity could catch it (since there is a valid escape sequence to
> generate '#elif' is needed).
> 
> I think this is the behavior of standard C/CPP preprocessors, they give
> an error if you try to use a invalid directive.
> 
> Tal
> 
> > -----Original Message-----
> > From: Dave Cramer [mailto:Dave@micro-automation.net]
> > Sent: Friday, July 20, 2001 1:37 AM
> > To: 'Tal Dayan'; velocity-user@jakarta.apache.org
> > Subject: RE: Any idea why this doesn't work
> >
> >
> > No exception. Velocity didn't understand it so it rendered it. This is
> 
> > ok in retrospect, velocitiy can't be expected to catch every mistake, 
> > and still do the "right" thing every where else
> >
> > Dave
> >
> > -----Original Message-----
> > From: Tal Dayan [mailto:tal@zapta.com]
> > Sent: July 20, 2001 12:38 AM
> > To: velocity-user@jakarta.apache.org; Dave@micro-automation.net
> > Subject: RE: Any idea why this doesn't work
> >
> >
> > Just curious, did you get an exception or an error message or did the 
> > execution (merging) of the template went silently about the error ?
> >
> > Tal
> >
> > > -----Original Message-----
> > > From: Dave Cramer [mailto:Dave@micro-automation.net]
> > > Sent: Thursday, July 19, 2001 6:56 PM
> > > To: velocity-user@jakarta.apache.org
> > > Subject: Any idea why this doesn't work
> > >
> > >
> > > The following works
> > >
> > >
> > > 	#if ($Store == 'Grocery')
> > >
> > >           <b>$Catalog.Render()</b>
> > >
> > >           <font face='Arial, Helvetica, sans-serif' size='2' 
> > > color='#000000'><b>
> > >             <b>
> > >             	<a 
> > > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> > >             		Movie Rental
> > >             	</a>
> > >             </b>
> > >   	      </font>
> > >         #end
> > >         #if ($Store == 'Rental')
> > >           #foreach ($store in $OpenedStores)
> > > 	  	      <b><a 
> > > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=
> > > Gr
> > > oc
> > > ery">
> > >             <font face="Arial, Helvetica, sans-serif" size="2"
> > > >$store.Name</font></a><br>
> > >           #end
> > >           <b>$Catalog.Render()</b>
> > > 	  #end
> > >
> > > But this doesn't
> > >
> > > 	#if ($Store == 'Grocery')
> > >
> > >           <b>$Catalog.Render()</b>
> > >
> > >           <font face='Arial, Helvetica, sans-serif' size='2' 
> > > color='#000000'><b>
> > >             <b>
> > >             	<a 
> > > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> > >             		Movie Rental
> > >             	</a>
> > >             </b>
> > >   	      </font>
> > >
> > >         #elif ($Store == 'Rental')
> > >           #foreach ($store in $OpenedStores)
> > > 	  	      <b><a 
> > > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=
> > > Gr
> > > oc
> > > ery">
> > >             <font face="Arial, Helvetica, sans-serif" size="2"
> > > >$store.Name</font></a><br>
> > >           #end
> > >           <b>$Catalog.Render()</b>
> > > 	  #end
> > >
> > > The difference is the #end #if was changed to #elif. When the 
> > > template
> >
> > > is displayed I see #elif (xxx == 'Grocery') on the page
> > >
> > > TIA,
> > >
> > > Dave
> > >
> > >
> >
> >
> >
> 
> 
> 

Re: Observation

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Dave Cramer wrote:
> 
> I had a quick look at the code, and it looks like
> 
> #if ($Object.Long == $Object.Integer) would return false even if they
> were equal in value

Yes - we don't do comparisons of anything but Integer and String.  It's
something we are working on, carefully.

> 
> Most compilers deal with this by promoting the smaller object to the
> larger, but this adds a lot of overhead.

Yes, and this isn't a programming language. :)
 
> A really easy way to deal with this is see if both sides are instances
> of Number and then compare their toString values.
> 
> I haven't tried the above so if I'm totally out of it, please ignore

No, this is valid.

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Observation

Posted by Dave Cramer <Da...@micro-automation.net>.
I had a quick look at the code, and it looks like 

#if ($Object.Long == $Object.Integer) would return false even if they
were equal in value

Most compilers deal with this by promoting the smaller object to the
larger, but this adds a lot of overhead.

A really easy way to deal with this is see if both sides are instances
of Number and then compare their toString values. 

I haven't tried the above so if I'm totally out of it, please ignore

Dave


RE: Any idea why this doesn't work

Posted by Paulo Gaspar <pa...@krankikom.de>.
My 2 cents:
Considering the pros and cons I also prefer the current behavior.

Have fun,
Paulo Gaspar

> -----Original Message-----
> From: Dave Cramer [mailto:Dave@micro-automation.net]
> Sent: Friday, July 20, 2001 11:34 AM
> 
> 
> Tal,
> 
> That would mean that everywhere there was an # we would get an error.
> This may be useful, but would generate a lot of error messages (colour
> definitions for example) . 
> 
> Dave
> 
> -----Original Message-----
> From: Tal Dayan [mailto:tal@zapta.com] 
> Sent: July 20, 2001 5:31 AM
> To: Dave@micro-automation.net; velocity-user@jakarta.apache.org
> Subject: RE: Any idea why this doesn't work
> 
> 
> I am not sure about that. '#elif' looks like an invalid directive, so
> Velocity could catch it (since there is a valid escape sequence to
> generate '#elif' is needed).
> 
> I think this is the behavior of standard C/CPP preprocessors, they give
> an error if you try to use a invalid directive.
> 
> Tal
> 
> > -----Original Message-----
> > From: Dave Cramer [mailto:Dave@micro-automation.net]
> > Sent: Friday, July 20, 2001 1:37 AM
> > To: 'Tal Dayan'; velocity-user@jakarta.apache.org
> > Subject: RE: Any idea why this doesn't work
> >
> >
> > No exception. Velocity didn't understand it so it rendered it. This is
> 
> > ok in retrospect, velocitiy can't be expected to catch every mistake, 
> > and still do the "right" thing every where else
> >
> > Dave
> >
> > -----Original Message-----
> > From: Tal Dayan [mailto:tal@zapta.com]
> > Sent: July 20, 2001 12:38 AM
> > To: velocity-user@jakarta.apache.org; Dave@micro-automation.net
> > Subject: RE: Any idea why this doesn't work
> >
> >
> > Just curious, did you get an exception or an error message or did the 
> > execution (merging) of the template went silently about the error ?
> >
> > Tal
> >
> > > -----Original Message-----
> > > From: Dave Cramer [mailto:Dave@micro-automation.net]
> > > Sent: Thursday, July 19, 2001 6:56 PM
> > > To: velocity-user@jakarta.apache.org
> > > Subject: Any idea why this doesn't work
> > >
> > >
> > > The following works
> > >
> > >
> > > 	#if ($Store == 'Grocery')
> > >
> > >           <b>$Catalog.Render()</b>
> > >
> > >           <font face='Arial, Helvetica, sans-serif' size='2' 
> > > color='#000000'><b>
> > >             <b>
> > >             	<a 
> > > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> > >             		Movie Rental
> > >             	</a>
> > >             </b>
> > >   	      </font>
> > >         #end
> > >         #if ($Store == 'Rental')
> > >           #foreach ($store in $OpenedStores)
> > > 	  	      <b><a 
> > > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=
> > > Gr
> > > oc
> > > ery">
> > >             <font face="Arial, Helvetica, sans-serif" size="2"
> > > >$store.Name</font></a><br>
> > >           #end
> > >           <b>$Catalog.Render()</b>
> > > 	  #end
> > >
> > > But this doesn't
> > >
> > > 	#if ($Store == 'Grocery')
> > >
> > >           <b>$Catalog.Render()</b>
> > >
> > >           <font face='Arial, Helvetica, sans-serif' size='2' 
> > > color='#000000'><b>
> > >             <b>
> > >             	<a 
> > > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> > >             		Movie Rental
> > >             	</a>
> > >             </b>
> > >   	      </font>
> > >
> > >         #elif ($Store == 'Rental')
> > >           #foreach ($store in $OpenedStores)
> > > 	  	      <b><a 
> > > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=
> > > Gr
> > > oc
> > > ery">
> > >             <font face="Arial, Helvetica, sans-serif" size="2"
> > > >$store.Name</font></a><br>
> > >           #end
> > >           <b>$Catalog.Render()</b>
> > > 	  #end
> > >
> > > The difference is the #end #if was changed to #elif. When the 
> > > template
> >
> > > is displayed I see #elif (xxx == 'Grocery') on the page
> > >
> > > TIA,
> > >
> > > Dave
> > >
> > >
> >
> >
> >
> 
> 

RE: Any idea why this doesn't work

Posted by Dave Cramer <Da...@micro-automation.net>.
Tal,

That would mean that everywhere there was an # we would get an error.
This may be useful, but would generate a lot of error messages (colour
definitions for example) . 

Dave

-----Original Message-----
From: Tal Dayan [mailto:tal@zapta.com] 
Sent: July 20, 2001 5:31 AM
To: Dave@micro-automation.net; velocity-user@jakarta.apache.org
Subject: RE: Any idea why this doesn't work


I am not sure about that. '#elif' looks like an invalid directive, so
Velocity could catch it (since there is a valid escape sequence to
generate '#elif' is needed).

I think this is the behavior of standard C/CPP preprocessors, they give
an error if you try to use a invalid directive.

Tal

> -----Original Message-----
> From: Dave Cramer [mailto:Dave@micro-automation.net]
> Sent: Friday, July 20, 2001 1:37 AM
> To: 'Tal Dayan'; velocity-user@jakarta.apache.org
> Subject: RE: Any idea why this doesn't work
>
>
> No exception. Velocity didn't understand it so it rendered it. This is

> ok in retrospect, velocitiy can't be expected to catch every mistake, 
> and still do the "right" thing every where else
>
> Dave
>
> -----Original Message-----
> From: Tal Dayan [mailto:tal@zapta.com]
> Sent: July 20, 2001 12:38 AM
> To: velocity-user@jakarta.apache.org; Dave@micro-automation.net
> Subject: RE: Any idea why this doesn't work
>
>
> Just curious, did you get an exception or an error message or did the 
> execution (merging) of the template went silently about the error ?
>
> Tal
>
> > -----Original Message-----
> > From: Dave Cramer [mailto:Dave@micro-automation.net]
> > Sent: Thursday, July 19, 2001 6:56 PM
> > To: velocity-user@jakarta.apache.org
> > Subject: Any idea why this doesn't work
> >
> >
> > The following works
> >
> >
> > 	#if ($Store == 'Grocery')
> >
> >           <b>$Catalog.Render()</b>
> >
> >           <font face='Arial, Helvetica, sans-serif' size='2' 
> > color='#000000'><b>
> >             <b>
> >             	<a 
> > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> >             		Movie Rental
> >             	</a>
> >             </b>
> >   	      </font>
> >         #end
> >         #if ($Store == 'Rental')
> >           #foreach ($store in $OpenedStores)
> > 	  	      <b><a 
> > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=
> > Gr
> > oc
> > ery">
> >             <font face="Arial, Helvetica, sans-serif" size="2"
> > >$store.Name</font></a><br>
> >           #end
> >           <b>$Catalog.Render()</b>
> > 	  #end
> >
> > But this doesn't
> >
> > 	#if ($Store == 'Grocery')
> >
> >           <b>$Catalog.Render()</b>
> >
> >           <font face='Arial, Helvetica, sans-serif' size='2' 
> > color='#000000'><b>
> >             <b>
> >             	<a 
> > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> >             		Movie Rental
> >             	</a>
> >             </b>
> >   	      </font>
> >
> >         #elif ($Store == 'Rental')
> >           #foreach ($store in $OpenedStores)
> > 	  	      <b><a 
> > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=
> > Gr
> > oc
> > ery">
> >             <font face="Arial, Helvetica, sans-serif" size="2"
> > >$store.Name</font></a><br>
> >           #end
> >           <b>$Catalog.Render()</b>
> > 	  #end
> >
> > The difference is the #end #if was changed to #elif. When the 
> > template
>
> > is displayed I see #elif (xxx == 'Grocery') on the page
> >
> > TIA,
> >
> > Dave
> >
> >
>
>
>



RE: Any idea why this doesn't work

Posted by Tal Dayan <ta...@zapta.com>.
I am not sure about that. '#elif' looks like an invalid directive, so
Velocity
could catch it (since there is a valid escape sequence to generate
'#elif' is needed).

I think this is the behavior of standard C/CPP preprocessors, they give an
error if you try to use a invalid directive.

Tal

> -----Original Message-----
> From: Dave Cramer [mailto:Dave@micro-automation.net]
> Sent: Friday, July 20, 2001 1:37 AM
> To: 'Tal Dayan'; velocity-user@jakarta.apache.org
> Subject: RE: Any idea why this doesn't work
>
>
> No exception. Velocity didn't understand it so it rendered it. This is
> ok in retrospect, velocitiy can't be expected to catch every mistake,
> and still do the "right" thing every where else
>
> Dave
>
> -----Original Message-----
> From: Tal Dayan [mailto:tal@zapta.com]
> Sent: July 20, 2001 12:38 AM
> To: velocity-user@jakarta.apache.org; Dave@micro-automation.net
> Subject: RE: Any idea why this doesn't work
>
>
> Just curious, did you get an exception or an error message or did the
> execution (merging) of the template went silently about the error ?
>
> Tal
>
> > -----Original Message-----
> > From: Dave Cramer [mailto:Dave@micro-automation.net]
> > Sent: Thursday, July 19, 2001 6:56 PM
> > To: velocity-user@jakarta.apache.org
> > Subject: Any idea why this doesn't work
> >
> >
> > The following works
> >
> >
> > 	#if ($Store == 'Grocery')
> >
> >           <b>$Catalog.Render()</b>
> >
> >           <font face='Arial, Helvetica, sans-serif' size='2'
> > color='#000000'><b>
> >             <b>
> >             	<a
> > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> >             		Movie Rental
> >             	</a>
> >             </b>
> >   	      </font>
> >         #end
> >         #if ($Store == 'Rental')
> >           #foreach ($store in $OpenedStores)
> > 	  	      <b><a
> > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Gr
> > oc
> > ery">
> >             <font face="Arial, Helvetica, sans-serif" size="2"
> > >$store.Name</font></a><br>
> >           #end
> >           <b>$Catalog.Render()</b>
> > 	  #end
> >
> > But this doesn't
> >
> > 	#if ($Store == 'Grocery')
> >
> >           <b>$Catalog.Render()</b>
> >
> >           <font face='Arial, Helvetica, sans-serif' size='2'
> > color='#000000'><b>
> >             <b>
> >             	<a
> > href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
> >             		Movie Rental
> >             	</a>
> >             </b>
> >   	      </font>
> >
> >         #elif ($Store == 'Rental')
> >           #foreach ($store in $OpenedStores)
> > 	  	      <b><a
> > href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Gr
> > oc
> > ery">
> >             <font face="Arial, Helvetica, sans-serif" size="2"
> > >$store.Name</font></a><br>
> >           #end
> >           <b>$Catalog.Render()</b>
> > 	  #end
> >
> > The difference is the #end #if was changed to #elif. When the template
>
> > is displayed I see #elif (xxx == 'Grocery') on the page
> >
> > TIA,
> >
> > Dave
> >
> >
>
>
>


RE: Any idea why this doesn't work

Posted by Dave Cramer <Da...@micro-automation.net>.
No exception. Velocity didn't understand it so it rendered it. This is
ok in retrospect, velocitiy can't be expected to catch every mistake,
and still do the "right" thing every where else

Dave

-----Original Message-----
From: Tal Dayan [mailto:tal@zapta.com] 
Sent: July 20, 2001 12:38 AM
To: velocity-user@jakarta.apache.org; Dave@micro-automation.net
Subject: RE: Any idea why this doesn't work


Just curious, did you get an exception or an error message or did the 
execution (merging) of the template went silently about the error ?

Tal

> -----Original Message-----
> From: Dave Cramer [mailto:Dave@micro-automation.net]
> Sent: Thursday, July 19, 2001 6:56 PM
> To: velocity-user@jakarta.apache.org
> Subject: Any idea why this doesn't work
> 
> 
> The following works
> 
> 
> 	#if ($Store == 'Grocery')
> 
>           <b>$Catalog.Render()</b>
>           
>           <font face='Arial, Helvetica, sans-serif' size='2' 
> color='#000000'><b>
>             <b>
>             	<a 
> href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
>             		Movie Rental
>             	</a>
>             </b>
>   	      </font>
>         #end
>         #if ($Store == 'Rental') 
>           #foreach ($store in $OpenedStores)
> 	  	      <b><a 
> href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Gr
> oc
> ery">
>             <font face="Arial, Helvetica, sans-serif" size="2"
> >$store.Name</font></a><br>
>           #end
>           <b>$Catalog.Render()</b>
> 	  #end
> 
> But this doesn't
> 
> 	#if ($Store == 'Grocery')
> 
>           <b>$Catalog.Render()</b>
>           
>           <font face='Arial, Helvetica, sans-serif' size='2' 
> color='#000000'><b>
>             <b>
>             	<a 
> href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
>             		Movie Rental
>             	</a>
>             </b>
>   	      </font>
>         
>         #elif ($Store == 'Rental') 
>           #foreach ($store in $OpenedStores)
> 	  	      <b><a 
> href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Gr
> oc
> ery">
>             <font face="Arial, Helvetica, sans-serif" size="2"
> >$store.Name</font></a><br>
>           #end
>           <b>$Catalog.Render()</b>
> 	  #end
> 
> The difference is the #end #if was changed to #elif. When the template

> is displayed I see #elif (xxx == 'Grocery') on the page
> 
> TIA,
> 
> Dave
> 
> 



RE: Any idea why this doesn't work

Posted by Tal Dayan <ta...@zapta.com>.
Just curious, did you get an exception or an error message or did the 
execution (merging) of the template went silently about the error ?

Tal

> -----Original Message-----
> From: Dave Cramer [mailto:Dave@micro-automation.net]
> Sent: Thursday, July 19, 2001 6:56 PM
> To: velocity-user@jakarta.apache.org
> Subject: Any idea why this doesn't work
> 
> 
> The following works
> 
> 
> 	#if ($Store == 'Grocery') 
> 
>           <b>$Catalog.Render()</b>
>           
>           <font face='Arial, Helvetica, sans-serif' size='2'
> color='#000000'><b>
>             <b>
>             	<a
> href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
>             		Movie Rental
>             	</a>
>             </b>
>   	      </font>
>         #end
>         #if ($Store == 'Rental') 
>           #foreach ($store in $OpenedStores)
> 	  	      <b><a
> href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Groc
> ery">
>             <font face="Arial, Helvetica, sans-serif" size="2"
> >$store.Name</font></a><br>
>           #end
>           <b>$Catalog.Render()</b>
> 	  #end
> 
> But this doesn't
> 
> 	#if ($Store == 'Grocery') 
> 
>           <b>$Catalog.Render()</b>
>           
>           <font face='Arial, Helvetica, sans-serif' size='2'
> color='#000000'><b>
>             <b>
>             	<a
> href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
>             		Movie Rental
>             	</a>
>             </b>
>   	      </font>
>         
>         #elif ($Store == 'Rental') 
>           #foreach ($store in $OpenedStores)
> 	  	      <b><a
> href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Groc
> ery">
>             <font face="Arial, Helvetica, sans-serif" size="2"
> >$store.Name</font></a><br>
>           #end
>           <b>$Catalog.Render()</b>
> 	  #end
> 
> The difference is the #end #if was changed to #elif. When the template
> is displayed I see #elif (xxx == 'Grocery') on the page
> 
> TIA,
> 
> Dave
> 
> 

Any idea why this doesn't work

Posted by Dave Cramer <Da...@micro-automation.net>.
The following works


	#if ($Store == 'Grocery') 

          <b>$Catalog.Render()</b>
          
          <font face='Arial, Helvetica, sans-serif' size='2'
color='#000000'><b>
            <b>
            	<a
href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
            		Movie Rental
            	</a>
            </b>
  	      </font>
        #end
        #if ($Store == 'Rental') 
          #foreach ($store in $OpenedStores)
	  	      <b><a
href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Groc
ery">
            <font face="Arial, Helvetica, sans-serif" size="2"
>$store.Name</font></a><br>
          #end
          <b>$Catalog.Render()</b>
	  #end

But this doesn't

	#if ($Store == 'Grocery') 

          <b>$Catalog.Render()</b>
          
          <font face='Arial, Helvetica, sans-serif' size='2'
color='#000000'><b>
            <b>
            	<a
href="$target?Command=catalog&amp;CategoryID=1100&amp;Store=Rental">
            		Movie Rental
            	</a>
            </b>
  	      </font>
        
        #elif ($Store == 'Rental') 
          #foreach ($store in $OpenedStores)
	  	      <b><a
href="$target?Command=catalog&amp;CategoryID=$store.CatId&amp;Store=Groc
ery">
            <font face="Arial, Helvetica, sans-serif" size="2"
>$store.Name</font></a><br>
          #end
          <b>$Catalog.Render()</b>
	  #end

The difference is the #end #if was changed to #elif. When the template
is displayed I see #elif (xxx == 'Grocery') on the page

TIA,

Dave


Re: Instantiable Velocity Engine

Posted by piero de salvia <pi...@yahoo.com>.
thinking about it,

maybe I need to move handleRequest() inside of
VelocityServlet.mergeTemplate()and do 
VelocityEngine.mergeTemplate in there, don't I ?

--- piero de salvia <pi...@yahoo.com> wrote:
> Hello everybody,
> 
> I am trying the instantiable VE in the Velocity
> servlet ( a modified versione of mine ) and,
> although
> I can do this : (vEngine = new VelocityEngine())
> 
> public Template getTemplate( String name )
>         throws ResourceNotFoundException,           
>  
> ParseErrorException, Exception
> {
> return vEngine.getTemplate(name);
> }
> 
> I cannot do this:
> 
> protected void mergeTemplate( Template template....
> {
> ...
> vEngine.mergeTemplate(template, context, vw);
> ....
> }
> 
> In the example app first arg is a String, but the
> servlet need to do getTemplate and Merge in two
> steps...
> 
> I tried to look into the source but it won't open,
> it
> seems corrupted (I am on Window$ - cannot do
> differently right now)
> 
> piero de salvia
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/