velocity - dollar sign

303 views
Skip to first unread message

Moa. M.

unread,
Aug 27, 2012, 12:59:18 PM8/27/12
to dot...@googlegroups.com
Hello

I have a structure for products with some text, select and image fields.
We use a text field to store a products price as follow : price $  (20 $)
that generate this error:

2012-08-27 12:23:20,833 ERROR org.apache.velocity.app.VelocityEngine - ResourceManager.getResource() parse exception
org.apache.velocity.exception.ParseErrorException: Lexical error: org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 1, column 5.  Encountered: <EOF> after : ""
    at org.apache.velocity.Template.process(Template.java:141)
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:446)
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:354)
    at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1420)
    at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1399)
    at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:401)
    at com.dotmarketing.viewtools.VelocityWebUtil.mergeTemplate(VelocityWebUtil.java:64)
    at sun.reflect.GeneratedMethodAccessor635.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
    at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
    at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
    at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
    at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:507)
    at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:155)
    at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
    at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:507)
    at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
    at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
    at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:346)
    at org.apache.velocity.Template.merge(Template.java:328)
    at org.apache.velocity.Template.merge(Template.java:235)
    at com.dotmarketing.viewtools.VelocityWebUtil.mergeTemplate(VelocityWebUtil.java:65)
    at sun.reflect.GeneratedMethodAccessor635.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
    at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
    at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
    at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
    at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:342)
    at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
    at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
    at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
    at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:212)
    at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:247)
    at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
    at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
    at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:346)
    at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:106)
    at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
    at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:212)
    at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:247)
    at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
    at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
    at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
    at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:346)
    at org.apache.velocity.runtime.directive.Parse.render(Parse.java:260)
    at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
    at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:346)
    at org.apache.velocity.Template.merge(Template.java:328)
    at org.apache.velocity.Template.merge(Template.java:235)
    at com.dotmarketing.viewtools.VelocityWebUtil.mergeTemplate(VelocityWebUtil.java:65)
    at sun.reflect.GeneratedMethodAccessor635.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
    at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
    at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
    at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
    at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:342)
    at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
    at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
    at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:346)
    at org.apache.velocity.Template.merge(Template.java:328)
    at org.apache.velocity.Template.merge(Template.java:235)
    at com.dotmarketing.velocity.VelocityServlet.doLiveMode(VelocityServlet.java:542)
    at com.dotmarketing.velocity.VelocityServlet.service(VelocityServlet.java:233)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
    at com.dotmarketing.cms.urlmap.filters.URLMapFilter.doFilter(URLMapFilter.java:302)
.......
2012-08-27 12:23:20,835 ERROR com.dotmarketing.viewtools.VelocityWebUtil - mergeTemplate

does anyone have an idea how to escape that dollar sign?

i m using dotcms 1.9.5 and that error appears after upgrading from 1.9.2

thanks

Maria Ahues Bouza

unread,
Aug 27, 2012, 1:15:03 PM8/27/12
to dot...@googlegroups.com
You can escape $ like this

${esc.d}

and # like this

${esc.h}



--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/dotcms/-/BsPOmO8BB1MJ.
To post to this group, send email to dot...@googlegroups.com.
To unsubscribe from this group, send email to dotcms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dotcms?hl=en.



--
Community Manager

dotCMS
Main: 305.900.2001
Fax: 305.397.2579
www.dotcms.com
http://www.twitter.com/dotCMS
http://www.facebook.com/dotCMS
http://www.twitter.com/mabouza

Please consider the planet before printing this email.

Maria Ahues Bouza

unread,
Aug 27, 2012, 1:16:13 PM8/27/12
to dot...@googlegroups.com
to make it easier on the content contributor why don't you remove the $ from the field and use it on the widget where you display the price?

That way they only need to enter

Price: 20

and on the widget where you are displaying the price you do

$content.price ${esc.d}



On Mon, Aug 27, 2012 at 9:59 AM, Moa. M. <moa...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/dotcms/-/BsPOmO8BB1MJ.
To post to this group, send email to dot...@googlegroups.com.
To unsubscribe from this group, send email to dotcms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dotcms?hl=en.

Mark Pitely

unread,
Aug 27, 2012, 1:16:22 PM8/27/12
to dot...@googlegroups.com
Moa,

For starters, this HTML code will render as a dollar sign:
&#36;
? You can try to use the Velocity escape sequence:
## The following line defines $email in this template:
#set( $email = "foo" )
$email
\$email
or this will render just a dollar sign as well:
${esc.d}



Depending on how you are processing this structure, you might be able to fix this on the fly with a string replacement. This error is coming when you perform a pull. Is this error coming only on a page you perform a pull on?
Something like this might work:
#set ($fixedamount=$con.amount.replaceAll("$", "&#36;"))
$fixedamount

Mark Pitely








Moa. M.

unread,
Aug 27, 2012, 1:26:01 PM8/27/12
to dot...@googlegroups.com
Thanks!
Reply all
Reply to author
Forward
0 new messages