You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Steve O'Hara <so...@pivotal-solutions.co.uk> on 2007/02/22 02:06:04 UTC
Escaping double quotes in v1.5 beta 2
I've been racking my brains trying to find a way to solve the double
quotes problem in 1.4 and finally gave in and moved up to 1.5 believing
that it is now all fixed..... However, the following gives me a parser
error at the use of the "".
#set ($Anchor="<a href='javascript:void(0)'
onclick='OpenAttachmentsWindow(""$AppPath/file/database?datasrc=$DataSou
rce&view=document&key=$Key&${UniqueNumber}${velocityCount}.${FileExt}"")
'>")
What am I doing wrong?
Thans,
Steve
-----Original Message-----
From:
user-return-18634-sohara=pivotal-solutions.co.uk@velocity.apache.org
[mailto:user-return-18634-sohara=pivotal-solutions.co.uk@velocity.apache
.org] On Behalf Of janbrito
Sent: 21 February 2007 18:52
To: user@velocity.apache.org
Subject: Re: [ANNOUNCE] Velocity-Struts
Thanks for your help Nathan. My application is running ok now. I forgot
to
mention that I was also using Spring framework so what I did was update
all
the libraries I was using (Spring 2.0.2 and Velocity 1.5) and now the
application works fine.
Thanks for your time Nathan.
Nathan Bubna wrote:
>
> Are you still using Velocity 1.4? I'm pretty sure that it's not
> possible to get that same error with Velocity 1.5-beta2. Also, can
> you send the log output? And have you tried running the
> velocity-struts example app?
>
> On 2/21/07, janbrito <ja...@msn.com> wrote:
>>
>> Hi Nathan,
>>
>> Thanks for your comments. I made the changes but I'm still getting
the
>> same
>> error when $msg.label.portal.welcome gets executed. It's like for
some
>> reason Velocity can't see the Struts ApplicationResource file and
can't
>> find
>> the message.
>>
>> Any body see what's missing here?
>>
>> Thanks
>>
>>
>> Nathan Bubna wrote:
>> >
>> > On 2/20/07, janbrito <ja...@msn.com> wrote:
>> >>
>> >> Hi, I'm trying to get Velocity working on a struts application.
This
>> is
>> >> what
>> >> I've dono so far:
>> >
>> > Have you looked at the "struts" example application that comes with
>> > VelocityTools? That might help you find problems in your setup.
>> >
>> >> 1) Added to the project the velocity libraries (velocity-1.4.jar,
>> >> velocity-dep-1.4.jar and velocity-tools-1.3.jar)
>> >
>> > I strongly recommend upgrading to velocity-dep-1.5-beta2. It is
quite
>> > stable and contains numerous bug fixes and improvements. Velocity
>> > 1.5 final should be released in just a week or so, and there have
been
>> > few changes since 1.5-beta2.
>> >
>> >> 2) Added this to my web.xml file:
>> >>
>> >> <servlet>
>> >> <servlet-name>velocity</servlet-name>
>> >> <servlet-class>
>> >>
org.apache.velocity.tools.view.servlet.VelocityViewServlet
>> >> </servlet-class>
>> >> <init-param>
>> >> <param-name>org.apache.velocity.toolbox</param-name>
>> >> <param-value>/WEB-INF/toolbox.xml</param-value>
>> >> </init-param>
>> >> </servlet>
>> >>
>> >> <servlet-mapping>
>> >> <servlet-name>velocity</servlet-name>
>> >> <url-pattern>*.vm</url-pattern>
>> >> </servlet-mapping>
>> >
>> > looks good
>> >
>> >> 3) Created the toolbox.xml file in WEB-INF dir with this content:
>> >>
>> >> <?xml version="1.0"?>
>> >> <toolbox>
>> >> <tool>
>> >> <key>link</key>
>> >> <scope>request</scope>
>> >> <class>
>> >> org.apache.velocity.tools.struts.StrutsLinkTool
>> >> </class>
>> >> </tool>
>> >> <tool>
>> >> <key>msg</key>
>> >> <scope>request</scope>
>> >> <class>
>> >> org.apache.velocity.tools.struts.MessageTool
>> >> </class>
>> >> </tool>
>> >> <tool>
>> >> <key>errors</key>
>> >> <scope>request</scope>
>> >> <class>
>> >> org.apache.velocity.tools.struts.ErrorsTool
>> >> </class>
>> >> </tool>
>> >> <tool>
>> >> <key>form</key>
>> >> <scope>request</scope>
>> >> <class>
>> >> org.apache.velocity.tools.struts.FormTool
>> >> </class>
>> >> </tool>
>> >> <tool>
>> >> <key>tiles</key>
>> >> <scope>request</scope>
>> >> <class>
>> >> org.apache.velocity.tools.struts.TilesTool
>> >> </class>
>> >> </tool>
>> >> <tool>
>> >> <key>validator</key>
>> >> <scope>request</scope>
>> >> <class>
>> >> org.apache.velocity.tools.struts.ValidatorTool
>> >> </class>
>> >> </tool>
>> >> </toolbox>
>> >
>> > looks good.
>> >
>> >> 4) Created an example index.vm file with only this code:
>> >>
>> >> <html>
>> >> <head>
>> >> <title>$msg.get("label.portal.welcome")</title>
>> >> </head>
>> >> <body bgcolor="white">
>> >>
>> >> </body>
>> >> </html>
>> >
>> > looks fine, but you can simplify it a bit by changing
>> >
>> > $msg.get("label.portal.welcome") -> $msg.label.portal.welcome
>> >
>> >> label.portal.welcome is defined on my
ApplicationResource.properties
>> >> struts
>> >> file.
>> >>
>> >> When I access the index file I get the following error:
>> >>
>> >> VelocityViewServlet : Error processing a template for path
>> >> '/jsp/index.vm'
>> >>
>> >> java.lang.NullPointerException
>> >> at
>> >>
org.apache.velocity.io.VelocityWriter.write(VelocityWriter.java:319)
>> >> at
>> >
>> > i don't remember the exact trigger for this, but this is a bug
which
>> > has been fixed in Velocity 1.5-beta2.
>> >
>> > <snip/>
>> >>
>> >> So I pretty sure I've missed a step or two when setting Velocity
up :)
>> >
>> > i'm not sure. do you have logging setup?
>> >
>> >> Also, I would like to know how do I replace velocity tags with
>> database
>> >> values I retrieve on my action classes.
>> >
>> > in your action, put those database values into the
HttpServletRequest
>> > attributes:
>> >
>> > request.setAttribute("myDBValue", myDBValue);
>> >
>> > then, in your template, just do:
>> >
>> > $myDBValue
>> >
>> >
>> >> Thanks
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Velocity-Struts-tf3263441.html#a9071152
>> >> Sent from the Velocity - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >>
---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> >> For additional commands, e-mail: user-help@velocity.apache.org
>> >>
>> >>
>> >
>> >
---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: user-help@velocity.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Velocity-Struts-tf3263441.html#a9080785
>> Sent from the Velocity - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
--
View this message in context:
http://www.nabble.com/Velocity-Struts-tf3263441.html#a9086786
Sent from the Velocity - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Escaping double quotes in v1.5 beta 2
Posted by "Geir Magnusson Jr." <ge...@pobox.com>.
On Feb 21, 2007, at 11:19 PM, Nathan Bubna wrote:
> Ok, found some more info. It was on the user list. :) First, there
> were many discussions. Geir had some code to do \ escaping, but it
> never went in because we couldn't agree:
> http://marc.theaimsgroup.com/?l=velocity-
> user&m=101190076826580&w=2 (Jan 2002)
>
> Then Barbara suggested the "" and '' escaping, which quickly found
> consensus. Geir quickly came up with code for it, but it was then
> found to only be 99.99% backwards compatible. Anyone foolish enough
> to not put spaces between their string literal velocimacro parameters
> #foo("a""b") would find their macros receiving a single parameter
> 'a"b' instead of two params 'a'' and 'b'. Still, no one seemed
> opposed to breaking things for those people. Geir suggested defining
> the fact that a space was not required as a bug.
> http://marc.theaimsgroup.com/?t=101967216900003&r=1&w=2 (Apr 2002)
>
> So, it looked like we were set for it to go in:
> http://marc.theaimsgroup.com/?l=velocity-user&m=102407958509606&w=2
> (June 2002)
>
> But it appears it never made it in. Christoph wondered where it was
> in Nov 2003, but i don't see any response to that:
> http://marc.theaimsgroup.com/?l=velocity-user&m=106968934203535&w=2
>
> Geir? Is the code for this out there still? It looks like it'll be
> too late for 1.5, but perhaps we can get it in 1.6...
Yeah. Thank goodness I changed my retention policy for unaccepted
code from 5 years to 7 years or I would have deleted it just last
month! :)
(5 years... wow...)
I'll see what I can dig up.
geir
>
> On 2/21/07, Nathan Bubna <nb...@gmail.com> wrote:
>> having a hard time finding discussion about this in the archives. i
>> must not have the correct search terms. anyway, here's two places
>> where Geir and Christoph mention this. anyone remember if this was
>> actually implemented?
>>
>> http://marc2.theaimsgroup.com/?l=velocity-user&m=102756433303385&w=3
>>
>> http://marc2.theaimsgroup.com/?l=velocity-user&m=112264108203085&w=3
>>
>> On 2/21/07, Nathan Bubna <nb...@gmail.com> wrote:
>> > Hmm. That sucks, i can't get it to work either. Neither do i
>> see any
>> > testcases for it. I also thought Geir had implemented this
>> (might do
>> > some archive searching on this). But, i've long since been in the
>> > habit of doing the manual escaping quotes anyway and still do
>> without
>> > thinking about it:
>> >
>> > i typically have the EscapeTool (from VelocityTools) present and
>> just use:
>> >
>> > $esc.q
>> >
>> > before that i would always do:
>> >
>> > #set( $q = '"' )
>> >
>> > and use:
>> >
>> > $q
>> >
>> > the opposite works for single quotes too:
>> >
>> > #set( $s = "'" )
>> > $s
>> >
>> > On 2/21/07, Steve O'Hara <so...@pivotal-solutions.co.uk> wrote:
>> > > I've been racking my brains trying to find a way to solve the
>> double
>> > > quotes problem in 1.4 and finally gave in and moved up to 1.5
>> believing
>> > > that it is now all fixed..... However, the following gives me
>> a parser
>> > > error at the use of the "".
>> > >
>> > > #set ($Anchor="<a href='javascript:void(0)'
>> > > onclick='OpenAttachmentsWindow(""$AppPath/file/database?
>> datasrc=$DataSou
>> > > rce&view=document&key=$Key&${UniqueNumber}${velocityCount}.$
>> {FileExt}"")
>> > > '>")
>> > >
>> > > What am I doing wrong?
>> > >
>> > > Thans,
>> > >
>> > > Steve
>> >
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Escaping double quotes in v1.5 beta 2
Posted by Nathan Bubna <nb...@gmail.com>.
Ok, found some more info. It was on the user list. :) First, there
were many discussions. Geir had some code to do \ escaping, but it
never went in because we couldn't agree:
http://marc.theaimsgroup.com/?l=velocity-user&m=101190076826580&w=2 (Jan 2002)
Then Barbara suggested the "" and '' escaping, which quickly found
consensus. Geir quickly came up with code for it, but it was then
found to only be 99.99% backwards compatible. Anyone foolish enough
to not put spaces between their string literal velocimacro parameters
#foo("a""b") would find their macros receiving a single parameter
'a"b' instead of two params 'a'' and 'b'. Still, no one seemed
opposed to breaking things for those people. Geir suggested defining
the fact that a space was not required as a bug.
http://marc.theaimsgroup.com/?t=101967216900003&r=1&w=2 (Apr 2002)
So, it looked like we were set for it to go in:
http://marc.theaimsgroup.com/?l=velocity-user&m=102407958509606&w=2 (June 2002)
But it appears it never made it in. Christoph wondered where it was
in Nov 2003, but i don't see any response to that:
http://marc.theaimsgroup.com/?l=velocity-user&m=106968934203535&w=2
Geir? Is the code for this out there still? It looks like it'll be
too late for 1.5, but perhaps we can get it in 1.6...
On 2/21/07, Nathan Bubna <nb...@gmail.com> wrote:
> having a hard time finding discussion about this in the archives. i
> must not have the correct search terms. anyway, here's two places
> where Geir and Christoph mention this. anyone remember if this was
> actually implemented?
>
> http://marc2.theaimsgroup.com/?l=velocity-user&m=102756433303385&w=3
>
> http://marc2.theaimsgroup.com/?l=velocity-user&m=112264108203085&w=3
>
> On 2/21/07, Nathan Bubna <nb...@gmail.com> wrote:
> > Hmm. That sucks, i can't get it to work either. Neither do i see any
> > testcases for it. I also thought Geir had implemented this (might do
> > some archive searching on this). But, i've long since been in the
> > habit of doing the manual escaping quotes anyway and still do without
> > thinking about it:
> >
> > i typically have the EscapeTool (from VelocityTools) present and just use:
> >
> > $esc.q
> >
> > before that i would always do:
> >
> > #set( $q = '"' )
> >
> > and use:
> >
> > $q
> >
> > the opposite works for single quotes too:
> >
> > #set( $s = "'" )
> > $s
> >
> > On 2/21/07, Steve O'Hara <so...@pivotal-solutions.co.uk> wrote:
> > > I've been racking my brains trying to find a way to solve the double
> > > quotes problem in 1.4 and finally gave in and moved up to 1.5 believing
> > > that it is now all fixed..... However, the following gives me a parser
> > > error at the use of the "".
> > >
> > > #set ($Anchor="<a href='javascript:void(0)'
> > > onclick='OpenAttachmentsWindow(""$AppPath/file/database?datasrc=$DataSou
> > > rce&view=document&key=$Key&${UniqueNumber}${velocityCount}.${FileExt}"")
> > > '>")
> > >
> > > What am I doing wrong?
> > >
> > > Thans,
> > >
> > > Steve
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Escaping double quotes in v1.5 beta 2
Posted by Nathan Bubna <nb...@gmail.com>.
having a hard time finding discussion about this in the archives. i
must not have the correct search terms. anyway, here's two places
where Geir and Christoph mention this. anyone remember if this was
actually implemented?
http://marc2.theaimsgroup.com/?l=velocity-user&m=102756433303385&w=3
http://marc2.theaimsgroup.com/?l=velocity-user&m=112264108203085&w=3
On 2/21/07, Nathan Bubna <nb...@gmail.com> wrote:
> Hmm. That sucks, i can't get it to work either. Neither do i see any
> testcases for it. I also thought Geir had implemented this (might do
> some archive searching on this). But, i've long since been in the
> habit of doing the manual escaping quotes anyway and still do without
> thinking about it:
>
> i typically have the EscapeTool (from VelocityTools) present and just use:
>
> $esc.q
>
> before that i would always do:
>
> #set( $q = '"' )
>
> and use:
>
> $q
>
> the opposite works for single quotes too:
>
> #set( $s = "'" )
> $s
>
> On 2/21/07, Steve O'Hara <so...@pivotal-solutions.co.uk> wrote:
> > I've been racking my brains trying to find a way to solve the double
> > quotes problem in 1.4 and finally gave in and moved up to 1.5 believing
> > that it is now all fixed..... However, the following gives me a parser
> > error at the use of the "".
> >
> > #set ($Anchor="<a href='javascript:void(0)'
> > onclick='OpenAttachmentsWindow(""$AppPath/file/database?datasrc=$DataSou
> > rce&view=document&key=$Key&${UniqueNumber}${velocityCount}.${FileExt}"")
> > '>")
> >
> > What am I doing wrong?
> >
> > Thans,
> >
> > Steve
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Escaping double quotes in v1.5 beta 2
Posted by Nathan Bubna <nb...@gmail.com>.
Hmm. That sucks, i can't get it to work either. Neither do i see any
testcases for it. I also thought Geir had implemented this (might do
some archive searching on this). But, i've long since been in the
habit of doing the manual escaping quotes anyway and still do without
thinking about it:
i typically have the EscapeTool (from VelocityTools) present and just use:
$esc.q
before that i would always do:
#set( $q = '"' )
and use:
$q
the opposite works for single quotes too:
#set( $s = "'" )
$s
On 2/21/07, Steve O'Hara <so...@pivotal-solutions.co.uk> wrote:
> I've been racking my brains trying to find a way to solve the double
> quotes problem in 1.4 and finally gave in and moved up to 1.5 believing
> that it is now all fixed..... However, the following gives me a parser
> error at the use of the "".
>
> #set ($Anchor="<a href='javascript:void(0)'
> onclick='OpenAttachmentsWindow(""$AppPath/file/database?datasrc=$DataSou
> rce&view=document&key=$Key&${UniqueNumber}${velocityCount}.${FileExt}"")
> '>")
>
> What am I doing wrong?
>
> Thans,
>
> Steve
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org