You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Iván Escobedo <ie...@nacion.co.cr> on 2003/10/23 17:41:06 UTC

Use of JSP tags within velocity

Hi, is it possible to use JSP tags with or without parameters within Velocity, how can I do that?

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


Re: Use of JSP tags within velocity

Posted by Jonathan Revusky <re...@wanadoo.es>.
Nathan Bubna wrote:

 > Geir Magnusson Jr. said:
 >
 >> On Thursday, October 23, 2003, at 12:52 PM, Nathan Bubna wrote:
 >>
 >>> Geir Magnusson Jr said:
 >>>
 >>>> On Thursday, October 23, 2003, at 12:08 PM, Nathan Bubna wrote:
 >>>>
 >>>>> Iván Escobedo said:
 >>>>>
 >>>>>> Hi, is it possible to use JSP tags with or without parameters
 >>>>>> within Velocity, how can I do that?
 >>>>>
 >>>>>
 >>>>> no, there has been discussion about adding a tool for this to the
 >>>>> VelocityTools project, but it doesn't look likely to happen anytime
 >>>>> soon.
 >>>>
 >>>>
 >>>> why not?
 >>>
 >>>
 >>> do you recall...
 >>> start of the discussion...
 >>> http://marc.theaimsgroup.com/?l=velocity-dev&m=106135789023669&w=2
 >>> ensuing thread...
 >>> http://marc.theaimsgroup.com/?t=106141089100001&r=1&w=2
 >>>
 >>> i put the idea out there.  some dissented.  some supported.  but as
 >>> far as i
 >>> know, no one cared enough to do it.  i'm sure not gonna have time for
 >>> it
 >>> anytime soon.
 >>>
 >>> if someone wants to take a shot at it, i'd still support putting such
 >>> a tool
 >>> or directive into a contrib area or alongside veltag, at this point
 >>> i'm still
 >>> reluctant to put it in VelocityTools itself.
 >>
 >>
 >> What would be the problem with having it part of the tools again?  It
 >> clearly shouldn't be a directive, but what would be wrong with a tool?
 >
 >
 >
 > well, it definitely shouldn't be a directive distributed with the core,


I'm sort of curious about the mentality behind this. Why should features 
like this not be added to the core?

I mean, you state that it should not be in the core with such certainty, 
as if this proposition were so obvious. It almost seems as if you guys 
have the same reaction to adding features to the velocity core that a 
Christian might have to adding a new gospel to the New Testament or that 
a Muslim would have towards adding a new shura to the Holy Koran.

If something is generally useful, why not add it to the core 
distribution? That is surely where it would get the most usage. It also 
is the clearest, least ambiguous situation. The feature is supported, 
and it's part of the core product, thus, it's always there. And it does 
not seem to me that adding such things to the core causes any particular 
inconvenience to users who are not interested in that functionality.

Well, anyway, support for JSP taglibs is part of the FreeMarker core.

http://freemarker.org/docs/pgui_misc_servlet.html

But of course, we don't really have a separate tools project per se. If 
something is useful, we just include it in the main distribution. 
Different philosophy, I guess. <shrug>

Regards,

Jonathan Revusky
-- 
lead developer, FreeMarker project, http://freemarker.org/



 > but if
 > it were an optional directive in contrib, it might potentially 
support tags
 > with bodies.
 >
 > similarly, i have no problem with it being developed as a tool.  i'm 
just not
 > keen on supporting and distributing it as part of VelocityTools proper.
 > basically, that's because it would be a really ugly hack that depends 
on the
 > JSP API.  i much prefer taking the approach of ImportTool and 
TilesTool, where
 > we use the general servlet API to support including *any other* view
 > technology into Velocity templates.  there's no specific dependance 
on another
 > view tech's API, and we thereby don't encourage template 
designers/developers
 > to "uglify" their templates by adding JSP stuff to them.  but, as 
Scott Weaver
 > pointed out, there may be some 1% or less of cases where something 
like this
 > is the sanest solution.  for such cases, i think it would be 
beneficial to
 > have something like this in a contrib folder somewhere.
 >
 > Nathan Bubna
 > nathan@esha.com




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


Re: Use of JSP tags within velocity

Posted by Nathan Bubna <na...@esha.com>.
Geir Magnusson Jr. said:
...
> The [jsp tag] directive over at WebWork2 is darn cool...

:)  yeah, i think "neato" was the word i used.  it or something like it would
make a nice yin to veltag's yang.

Nathan Bubna
nathan@esha.com


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


Re: Use of JSP tags within velocity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Thursday, October 23, 2003, at 01:19 PM, Nathan Bubna wrote:

> Geir Magnusson Jr. said:
>> On Thursday, October 23, 2003, at 12:52 PM, Nathan Bubna wrote:
>>> Geir Magnusson Jr said:
>>>> On Thursday, October 23, 2003, at 12:08 PM, Nathan Bubna wrote:
>>>>> Iván Escobedo said:
>>>>>> Hi, is it possible to use JSP tags with or without parameters
>>>>>> within Velocity, how can I do that?
>>>>>
>>>>> no, there has been discussion about adding a tool for this to the
>>>>> VelocityTools project, but it doesn't look likely to happen anytime
>>>>> soon.
>>>>
>>>> why not?
>>>
>>> do you recall...
>>> start of the discussion...
>>> http://marc.theaimsgroup.com/?l=velocity-dev&m=106135789023669&w=2
>>> ensuing thread...
>>> http://marc.theaimsgroup.com/?t=106141089100001&r=1&w=2
>>>
>>> i put the idea out there.  some dissented.  some supported.  but as
>>> far as i
>>> know, no one cared enough to do it.  i'm sure not gonna have time for
>>> it
>>> anytime soon.
>>>
>>> if someone wants to take a shot at it, i'd still support putting such
>>> a tool
>>> or directive into a contrib area or alongside veltag, at this point
>>> i'm still
>>> reluctant to put it in VelocityTools itself.
>>
>> What would be the problem with having it part of the tools again?  It
>> clearly shouldn't be a directive, but what would be wrong with a tool?
>
> well, it definitely shouldn't be a directive distributed with the 
> core, but if
> it were an optional directive in contrib, it might potentially support 
> tags
> with bodies.
>
> similarly, i have no problem with it being developed as a tool.  i'm 
> just not
> keen on supporting and distributing it as part of VelocityTools proper.
> basically, that's because it would be a really ugly hack that depends 
> on the
> JSP API.  i much prefer taking the approach of ImportTool and 
> TilesTool, where
> we use the general servlet API to support including *any other* view
> technology into Velocity templates.  there's no specific dependance on 
> another
> view tech's API, and we thereby don't encourage template 
> designers/developers
> to "uglify" their templates by adding JSP stuff to them.  but, as 
> Scott Weaver
> pointed out, there may be some 1% or less of cases where something 
> like this
> is the sanest solution.  for such cases, i think it would be 
> beneficial to
> have something like this in a contrib folder somewhere.
>

The directive over at WebWork2 is darn cool...

-- 
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


Re: Use of JSP tags within velocity

Posted by Nathan Bubna <na...@esha.com>.
Geir Magnusson Jr. said:
> On Thursday, October 23, 2003, at 12:52 PM, Nathan Bubna wrote:
> > Geir Magnusson Jr said:
> >> On Thursday, October 23, 2003, at 12:08 PM, Nathan Bubna wrote:
> >>> Iván Escobedo said:
> >>>> Hi, is it possible to use JSP tags with or without parameters
> >>>> within Velocity, how can I do that?
> >>>
> >>> no, there has been discussion about adding a tool for this to the
> >>> VelocityTools project, but it doesn't look likely to happen anytime
> >>> soon.
> >>
> >> why not?
> >
> > do you recall...
> > start of the discussion...
> > http://marc.theaimsgroup.com/?l=velocity-dev&m=106135789023669&w=2
> > ensuing thread...
> > http://marc.theaimsgroup.com/?t=106141089100001&r=1&w=2
> >
> > i put the idea out there.  some dissented.  some supported.  but as
> > far as i
> > know, no one cared enough to do it.  i'm sure not gonna have time for
> > it
> > anytime soon.
> >
> > if someone wants to take a shot at it, i'd still support putting such
> > a tool
> > or directive into a contrib area or alongside veltag, at this point
> > i'm still
> > reluctant to put it in VelocityTools itself.
>
> What would be the problem with having it part of the tools again?  It
> clearly shouldn't be a directive, but what would be wrong with a tool?

well, it definitely shouldn't be a directive distributed with the core, but if
it were an optional directive in contrib, it might potentially support tags
with bodies.

similarly, i have no problem with it being developed as a tool.  i'm just not
keen on supporting and distributing it as part of VelocityTools proper.
basically, that's because it would be a really ugly hack that depends on the
JSP API.  i much prefer taking the approach of ImportTool and TilesTool, where
we use the general servlet API to support including *any other* view
technology into Velocity templates.  there's no specific dependance on another
view tech's API, and we thereby don't encourage template designers/developers
to "uglify" their templates by adding JSP stuff to them.  but, as Scott Weaver
pointed out, there may be some 1% or less of cases where something like this
is the sanest solution.  for such cases, i think it would be beneficial to
have something like this in a contrib folder somewhere.

Nathan Bubna
nathan@esha.com


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


Re: Use of JSP tags within velocity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Thursday, October 23, 2003, at 12:52 PM, Nathan Bubna wrote:

> Geir Magnusson Jr said:
>> On Thursday, October 23, 2003, at 12:08 PM, Nathan Bubna wrote:
>>> Iván Escobedo said:
>>>> Hi, is it possible to use JSP tags with or without parameters
>>>> within Velocity, how can I do that?
>>>
>>> no, there has been discussion about adding a tool for this to the
>>> VelocityTools project, but it doesn't look likely to happen anytime
>>> soon.
>>
>> why not?
>
> do you recall...
> start of the discussion...
> http://marc.theaimsgroup.com/?l=velocity-dev&m=106135789023669&w=2
> ensuing thread...
> http://marc.theaimsgroup.com/?t=106141089100001&r=1&w=2
>
> i put the idea out there.  some dissented.  some supported.  but as 
> far as i
> know, no one cared enough to do it.  i'm sure not gonna have time for 
> it
> anytime soon.
>
> if someone wants to take a shot at it, i'd still support putting such 
> a tool
> or directive into a contrib area or alongside veltag, at this point 
> i'm still
> reluctant to put it in VelocityTools itself.

What would be the problem with having it part of the tools again?  It 
clearly shouldn't be a directive, but what would be wrong with a tool?


-- 
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


Re: Use of JSP tags within velocity

Posted by Nathan Bubna <na...@esha.com>.
Geir Magnusson Jr said:
> On Thursday, October 23, 2003, at 12:08 PM, Nathan Bubna wrote:
> > Iván Escobedo said:
> >> Hi, is it possible to use JSP tags with or without parameters
> >> within Velocity, how can I do that?
> >
> > no, there has been discussion about adding a tool for this to the
> > VelocityTools project, but it doesn't look likely to happen anytime
> > soon.
>
> why not?

do you recall...
start of the discussion...
http://marc.theaimsgroup.com/?l=velocity-dev&m=106135789023669&w=2
ensuing thread...
http://marc.theaimsgroup.com/?t=106141089100001&r=1&w=2

i put the idea out there.  some dissented.  some supported.  but as far as i
know, no one cared enough to do it.  i'm sure not gonna have time for it
anytime soon.

if someone wants to take a shot at it, i'd still support putting such a tool
or directive into a contrib area or alongside veltag, at this point i'm still
reluctant to put it in VelocityTools itself.

Nathan Bubna
nathan@esha.com


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


Re: Use of JSP tags within velocity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Thursday, October 23, 2003, at 12:08 PM, Nathan Bubna wrote:

> Iván Escobedo said:
>> Hi, is it possible to use JSP tags with or without parameters
>> within Velocity, how can I do that?
>
> no, there has been discussion about adding a tool for this to the
> VelocityTools project, but it doesn't look likely to happen anytime 
> soon.

why not?

>
> you will, however, soon be able to mix and match velocity and jsp 
> files in the
> same page using the forthcoming ImportTool and/or TilesTool in the
> VelocityTools project.  and of course, the Veltag is always available 
> for
> including Velocity in JSP.
>
> Nathan Bubna
> nathan@esha.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@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


Re: Use of JSP tags within velocity

Posted by Nathan Bubna <na...@esha.com>.
Iván Escobedo said:
> Hi, is it possible to use JSP tags with or without parameters
> within Velocity, how can I do that?

no, there has been discussion about adding a tool for this to the
VelocityTools project, but it doesn't look likely to happen anytime soon.

you will, however, soon be able to mix and match velocity and jsp files in the
same page using the forthcoming ImportTool and/or TilesTool in the
VelocityTools project.  and of course, the Veltag is always available for
including Velocity in JSP.

Nathan Bubna
nathan@esha.com


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


Re: Use of JSP tags within velocity

Posted by Jonathan Revusky <re...@wanadoo.es>.
Iván Escobedo wrote:
> Hi, is it possible to use JSP tags with or without parameters within Velocity, how can I do that?


Iván,

Velocity seems to have gone for some kind of bare-bones templating 
"philosophy", where only the most minimal feature set is supported in 
order to keep the core engine small and simple.

That philosophy probably has its merits, but if you are interested in a 
template engine with a greater range of functionality, you might take a 
look at FreeMarker, http://freemarker.org/ which is a template engine 
much like Velocity (or really, Velocity is a template engine much like 
FreeMarker since FreeMarker is the older product.)

Anyway, FreeMarker has supported the use of 3rd party JSP taglibs for 
some time now. Also, there are various other features that Velocity 
users are constantly lobbying for -- decimal numbers, local variables in 
macros, and other things -- that are present in FreeMarker.

We also have an automatic template conversion tool that runs over your 
VEl templates and converts them to FM syntax. Though you then have to 
change your java code, of course.

Anyway, that could be helpful information.

Saludos desde España,

Jonathan Revusky
--
lead developer, FreeMarker project, http://freemarker.org/
FreeMarker-Velocity comparison page: http://freemarker.org/fmVsVel.html



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


RE: Use of JSP tags within velocity

Posted by Mike Curwen <gb...@gb-im.com>.
Well yes, but it's an alternative. And if you already happen to be using
Resin...

> -----Original Message-----
> From: Robert Douglass [mailto:r.douglass@onlinehome.de] 
> Sent: Thursday, October 23, 2003 11:08 AM
> To: Velocity Users List
> Subject: RE: Use of JSP tags within velocity
> 
> 
> doesn't that lock you into a container?
> 
> -----Original Message-----
> From: Mike Curwen [mailto:gb_dev@gb-im.com]
> Sent: Thursday, October 23, 2003 5:05 PM
> To: 'Velocity Users List'
> Subject: RE: Use of JSP tags within velocity
> 
> 
> I was reading up on Resin the other day, and they support 
> 'velocity-like' syntax.  Apparently resin will 'translate' 
> Velocity code into equivalent JSTL code, and then use *that* 
> as the JSP.
> 
> You might be able to mix Velocity and JSP in this way.
> 
> 
> 
> > -----Original Message-----
> > From: Robert Douglass [mailto:r.douglass@onlinehome.de]
> > Sent: Thursday, October 23, 2003 10:58 AM
> > To: Velocity Users List
> > Subject: RE: Use of JSP tags within velocity
> >
> >
> > WebWork2 offers the ability to call any JSP tag from any 
> library from 
> > a velocity view with the following syntax #tag( JSPTagName 
> > "param1=foo" "param2=bar")
> >
> > WebWork2 is currently approaching its second beta.
> >
> http://wiki.opensymphony.com/space/WebWork2
> 
> -RD
> 
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Thursday, October 23, 2003 4:53 PM
> To: Velocity Users List
> Subject: Re: Use of JSP tags within velocity
> 
> 
> 
> On Thursday, October 23, 2003, at 11:41 AM, Iván Escobedo wrote:
> 
> > Hi, is it possible to use JSP tags with or without 
> parameters within 
> > Velocity, how can I do that?
> >
> 
> No, not now.   You can use Velocity in JSP with the unsupoprted Veltag
> (in contrib).
> 
> We need to make our own little tool that we can offer people 
> to do this in tools-land...
> 
> geir
> 
> --
> 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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


RE: Use of JSP tags within velocity

Posted by Robert Douglass <r....@onlinehome.de>.
doesn't that lock you into a container?

-----Original Message-----
From: Mike Curwen [mailto:gb_dev@gb-im.com]
Sent: Thursday, October 23, 2003 5:05 PM
To: 'Velocity Users List'
Subject: RE: Use of JSP tags within velocity


I was reading up on Resin the other day, and they support
'velocity-like' syntax.  Apparently resin will 'translate' Velocity code
into equivalent JSTL code, and then use *that* as the JSP.

You might be able to mix Velocity and JSP in this way.



> -----Original Message-----
> From: Robert Douglass [mailto:r.douglass@onlinehome.de]
> Sent: Thursday, October 23, 2003 10:58 AM
> To: Velocity Users List
> Subject: RE: Use of JSP tags within velocity
>
>
> WebWork2 offers the ability to call any JSP tag from any
> library from a velocity view with the following syntax #tag(
> JSPTagName "param1=foo" "param2=bar")
>
> WebWork2 is currently approaching its second beta.
>
http://wiki.opensymphony.com/space/WebWork2

-RD

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Thursday, October 23, 2003 4:53 PM
To: Velocity Users List
Subject: Re: Use of JSP tags within velocity



On Thursday, October 23, 2003, at 11:41 AM, Iván Escobedo wrote:

> Hi, is it possible to use JSP tags with or without parameters within
> Velocity, how can I do that?
>

No, not now.   You can use Velocity in JSP with the unsupoprted Veltag
(in contrib).

We need to make our own little tool that we can offer people to do this
in tools-land...

geir

--
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


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


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


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


RE: Use of JSP tags within velocity

Posted by Mike Curwen <gb...@gb-im.com>.
I was reading up on Resin the other day, and they support
'velocity-like' syntax.  Apparently resin will 'translate' Velocity code
into equivalent JSTL code, and then use *that* as the JSP.
 
You might be able to mix Velocity and JSP in this way.



> -----Original Message-----
> From: Robert Douglass [mailto:r.douglass@onlinehome.de] 
> Sent: Thursday, October 23, 2003 10:58 AM
> To: Velocity Users List
> Subject: RE: Use of JSP tags within velocity
> 
> 
> WebWork2 offers the ability to call any JSP tag from any 
> library from a velocity view with the following syntax #tag( 
> JSPTagName "param1=foo" "param2=bar")
> 
> WebWork2 is currently approaching its second beta.
> 
http://wiki.opensymphony.com/space/WebWork2

-RD

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Thursday, October 23, 2003 4:53 PM
To: Velocity Users List
Subject: Re: Use of JSP tags within velocity



On Thursday, October 23, 2003, at 11:41 AM, Iván Escobedo wrote:

> Hi, is it possible to use JSP tags with or without parameters within 
> Velocity, how can I do that?
>

No, not now.   You can use Velocity in JSP with the unsupoprted Veltag
(in contrib).

We need to make our own little tool that we can offer people to do this
in tools-land...

geir

--
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


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


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


RE: Use of JSP tags within velocity

Posted by Robert Douglass <r....@onlinehome.de>.
WebWork2 offers the ability to call any JSP tag from any library from a
velocity view with the following syntax
#tag( JSPTagName "param1=foo" "param2=bar")

WebWork2 is currently approaching its second beta.

http://wiki.opensymphony.com/space/WebWork2

-RD

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Thursday, October 23, 2003 4:53 PM
To: Velocity Users List
Subject: Re: Use of JSP tags within velocity



On Thursday, October 23, 2003, at 11:41 AM, Iván Escobedo wrote:

> Hi, is it possible to use JSP tags with or without parameters within
> Velocity, how can I do that?
>

No, not now.   You can use Velocity in JSP with the unsupoprted Veltag
(in contrib).

We need to make our own little tool that we can offer people to do this
in tools-land...

geir

--
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


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


Re: [velocity-layout] getTemplate for e-mail

Posted by Nathan Bubna <na...@esha.com>.
Charles N. Harvey III said:
...
> I have to have my action class send out an e-mail and I want the e-mail
> formatted in a certain manner.  I have a email.vm file in my path, so
> how do i get it and then insert values like $userName into the template
> and then send it?

basic velocity template retrieval and rendering:
    Context ctx = new VelocityContext();
    ctx.put("userName", userName);
    Template template = Velocity.getTemplate("email.vm");
    template.merge(ctx, someWriter);

and that's as far as i can take you...

Nathan Bubna
nathan@esha.com


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


Re: [velocity-layout] getTemplate for e-mail

Posted by Mike Kienenberger <mk...@alaska.net>.
"Charles N. Harvey III" <ch...@alloy.com> wrote:
> Hello.
> I am using the VelocityLayoutServlet with Struts in an application
> and so far so good.  Been going along great for quite a few months
> now.
> 
> I have to have my action class send out an e-mail and I want the e-mail
> formatted in a certain manner.  I have a email.vm file in my path, so
> how do i get it and then insert values like $userName into the template
> and then send it?
> 
> I'm sure this is possible (and probably quite easy), I just haven't
> quite figured out how to do it.


What I use isn't much different from iescobedo@nacion.co.cr's solution -- 
it's just organized a little more differently (easier to reuse) and has some 
commented-out code that could be uncommented to use the commons word-wrapper 
class.

Example calling code:
===============================
		Context context = new VelocityContext();
		context.put("applicationName", 
GlobalParameterManager.getInstance().getApplicationName());
		context.put("activationCode", randomCode);
		context.put("user", aUser);
		context.put("userID", aUser.getUserName());
		context.put("oldEmailAddress", aUser.getEmailAddress());
		if (null != newEmailAddress)
		{
			context.put("DidEmailAddressChange", "true");
			context.put("newEmailAddress", newEmailAddress);
		}

		String body;
		try
		{
			body =
				createMessageBody(
					administrativeUser, selectedUser,
					CUSTOMER_EMAIL_TEMPLATE_DIRECTORY + "SendActivationCode.vm",
					context);
		}
		catch (ChainedException aChainedException)
		{
			// add your error handling here
		}
===============================


===============================
	private String createMessageBody(String aTemplateName, Context aContext) 
throws ChainedException
	{
		StringWriter writer = new StringWriter();
		try
		{
			Velocity.mergeTemplate(aTemplateName, "ISO8859-1", aContext, writer);
		}
		catch (ResourceNotFoundException aResourceNotFoundException)
		{
			ChainedException newChainedException = new 
ChainedException(aResourceNotFoundException, "Unable to load email template 
" + aTemplateName);
			
NotificationManager.getInstance().reportProgrammingError(newChainedException);
			throw newChainedException;
		}
		catch (ParseErrorException aParseErrorException)
		{
			ChainedException newChainedException = new 
ChainedException(aParseErrorException, "Unable to parse email template " + 
aTemplateName);
			
NotificationManager.getInstance().reportProgrammingError(newChainedException);
			throw newChainedException;
		}
		catch (MethodInvocationException aMethodInvocationException)
		{
			ChainedException newChainedException = new 
ChainedException(aMethodInvocationException, "Unable to parse email template 
" + aTemplateName);
			
NotificationManager.getInstance().reportProgrammingError(newChainedException);
			throw newChainedException;
		}
		catch (Exception anException)
		{
			ChainedException newChainedException = new ChainedException(anException, 
"Unable to parse email template " + aTemplateName);
			
NotificationManager.getInstance().reportProgrammingError(newChainedException);
			throw newChainedException;
		}
		
		String body = writer.toString();

//		int wordWrap = 0;
//		// If the caller desires word-wrapping, do it here
//		if (wordWrap > 0)
//			body = WordWrapper.wrapText(body, System.getProperty("line.separator"), 
wordWrap);
	
		return body;
	}
===============================

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


[velocity-layout] getTemplate for e-mail

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
Hello.
I am using the VelocityLayoutServlet with Struts in an application
and so far so good.  Been going along great for quite a few months
now.

I have to have my action class send out an e-mail and I want the e-mail
formatted in a certain manner.  I have a email.vm file in my path, so
how do i get it and then insert values like $userName into the template
and then send it?

I'm sure this is possible (and probably quite easy), I just haven't
quite figured out how to do it.

Any tips?

Thanks.


Charlie


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


Re: Use of JSP tags within velocity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
(replying to Matt using Nathan's email :)

On Thursday, October 23, 2003, at 01:31 PM, Nathan Bubna wrote:

> Matt Raible said:
>> VERY nice!  I know this is a dumb question for an OS project, but when
>> do you expect to commit/release these?
>
> I'm sure Marino will commit them once he's ready.  as for a 
> VelocityTools
> release:
> http://marc.theaimsgroup.com/?l=velocity-dev&m=106675339032634&w=2
>
>> I'm *really* looking forward to
>> the Local directive and the tools you mention below.  I realize that I
>> can checkout/build and keep my own version with these tools, but it's 
>> a
>> bit tough to convince my clients to accept my custom built OS projects
>> vs. a standard release.
>

I don't understand.  If you are delivering code to your clients, feel 
free to take that LocalDirective and package it in your code.  That's 
one of the underpinning philosophies of the license we use - you are 
free to take and use as you wish.  The only requirement is that you 
give us credit, somewhere.  Using our software in your distribution 
does not in any way 'taint' your code - it's still yours.

geir

-- 
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


Re: Use of JSP tags within velocity

Posted by Nathan Bubna <na...@esha.com>.
Matt Raible said:
> VERY nice!  I know this is a dumb question for an OS project, but when
> do you expect to commit/release these?

I'm sure Marino will commit them once he's ready.  as for a VelocityTools
release:
http://marc.theaimsgroup.com/?l=velocity-dev&m=106675339032634&w=2

> I'm *really* looking forward to
> the Local directive and the tools you mention below.  I realize that I
> can checkout/build and keep my own version with these tools, but it's a
> bit tough to convince my clients to accept my custom built OS projects
> vs. a standard release.

as Geir said, if there's something in a contrib you want, you don't have to
build it into your own custom Velocity or VelocityTools jar, you can just
distribute those particular classes in your own separate jar and use the
released versions of the projects.  not ideal, but might be an easier sell.

Nathan Bubna
nathan@esha.com


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


Re: Use of JSP tags within velocity

Posted by Matt Raible <ma...@raibledesigns.com>.
VERY nice!  I know this is a dumb question for an OS project, but when 
do you expect to commit/release these?  I'm *really* looking forward to 
the Local directive and the tools you mention below.  I realize that I 
can checkout/build and keep my own version with these tools, but it's a 
bit tough to convince my clients to accept my custom built OS projects 
vs. a standard release.

Thanks,

Matt

On Thursday, October 23, 2003, at 10:23 AM, Nathan Bubna wrote:

> Matt Raible said:
>> Is this possible to include a JSP in a Velocity template just like 
>> you'd
>> include a JSP in another JSP?
>
> yes.
>
> http://nagoya.apache.org/wiki/apachewiki.cgi?ImportTool
> http://nagoya.apache.org/wiki/apachewiki.cgi?NewTilesTool
>
> these should be committed to the VelocityTools project soon.
>
> Nathan Bubna
> nathan@esha.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org


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


Re: Use of JSP tags within velocity

Posted by Nathan Bubna <na...@esha.com>.
Matt Raible said:
> Is this possible to include a JSP in a Velocity template just like you'd
> include a JSP in another JSP?

yes.

http://nagoya.apache.org/wiki/apachewiki.cgi?ImportTool
http://nagoya.apache.org/wiki/apachewiki.cgi?NewTilesTool

these should be committed to the VelocityTools project soon.

Nathan Bubna
nathan@esha.com

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


RE: Use of JSP tags within velocity

Posted by Matt Raible <ma...@raibledesigns.com>.
Is this possible to include a JSP in a Velocity template just like you'd
include a JSP in another JSP?

Thanks,

Matt

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net] 
> Sent: Thursday, October 23, 2003 9:53 AM
> To: Velocity Users List
> Subject: Re: Use of JSP tags within velocity
> 
> 
> 
> On Thursday, October 23, 2003, at 11:41 AM, Iván Escobedo wrote:
> 
> > Hi, is it possible to use JSP tags with or without parameters within
> > Velocity, how can I do that?
> >
> 
> No, not now.   You can use Velocity in JSP with the 
> unsupoprted Veltag 
> (in contrib).
> 
> We need to make our own little tool that we can offer people 
> to do this 
> in tools-land...
> 
> geir
> 
> -- 
> 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
> 



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


Re: Use of JSP tags within velocity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Thursday, October 23, 2003, at 11:41 AM, Iván Escobedo wrote:

> Hi, is it possible to use JSP tags with or without parameters within 
> Velocity, how can I do that?
>

No, not now.   You can use Velocity in JSP with the unsupoprted Veltag 
(in contrib).

We need to make our own little tool that we can offer people to do this 
in tools-land...

geir

-- 
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