java - velocity template and javascript -
i try add javascript velocity template.
<html> <head> <title>:: $currency.currencyname detail info ::</title> </head> <body> <table> <tr> <td>name</td> <td>$currency.currencyname</td> </tr> <tr> <td>jual</td> <td><div id="$currency.currencyname_buy">$currency.buy</div></td> </tr> <tr> <td>beli</td> <td><div id="$currency.currencyname_sell">$currency.sell</div></td> </tr> </table> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> $(document).ready(function() { setinterval(function() { $.get('updatecurrency.htm', function(data) { $('#time').text(data); }); }, 5 * 60 * 1000); // 1000 milliseconds = 1 second. }); </script> <p>current date/time is: <span id="time"></span> </body> </html>
but got following error:
org.apache.velocity.exception.parseerrorexception: encountered "," @ line 28, column 29 of currencydetail.html expecting 1 of: <eof> "(" ... <rparen> ... <escape_directive> ... <set_directive> ... "##" ... "\\\\" ... "\\" ... <text> ... "*#" ... "*#" ... <string_literal> ... <if_directive> ... <stop_directive> ... <integer_literal> ... <floating_point_literal> ... <word> ... <bracketed_word> ... <identifier> ... <dot> ... "{" ... "}" ... @ org.apache.velocity.template.process(template.java:137) @ org.apache.velocity.runtime.resource.resourcemanagerimpl.loadresource(resourcemanagerimpl.java:415) @ org.apache.velocity.runtime.resource.resourcemanagerimpl.getresource(resourcemanagerimpl.java:335) @ org.apache.velocity.runtime.runtimeinstance.gettemplate(runtimeinstance.java:1102) @ org.apache.velocity.runtime.runtimeinstance.gettemplate(runtimeinstance.java:1077) @ org.apache.velocity.app.velocityengine.gettemplate(velocityengine.java:528) @ org.springframework.web.servlet.view.velocity.velocityview.gettemplate(velocityview.java:535) @ org.springframework.web.servlet.view.velocity.velocityview.gettemplate(velocityview.java:520) @ org.springframework.web.servlet.view.velocity.velocityview.checktemplate(velocityview.java:293) @ org.springframework.web.servlet.view.velocity.velocityview.initapplicationcontext(velocityview.java:258) @ org.springframework.context.support.applicationobjectsupport.setapplicationcontext(applicationobjectsupport.java:73) @ org.springframework.context.support.applicationcontextawareprocessor.postprocessbeforeinitialization(applicationcontextawareprocessor.java:70) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.applybeanpostprocessorsbeforeinitialization(abstractautowirecapablebeanfactory.java:323) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1355) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:314) @ org.springframework.web.servlet.view.urlbasedviewresolver.loadview(urlbasedviewresolver.java:413) @ org.springframework.web.servlet.view.abstractcachingviewresolver.createview(abstractcachingviewresolver.java:159) @ org.springframework.web.servlet.view.urlbasedviewresolver.createview(urlbasedviewresolver.java:378) @ org.springframework.web.servlet.view.abstractcachingviewresolver.resolveviewname(abstractcachingviewresolver.java:78) @ org.springframework.web.servlet.dispatcherservlet.resolveviewname(dispatcherservlet.java:1190) @ org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1139) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:900) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:808) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:476) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:431) @ javax.servlet.http.httpservlet.service(httpservlet.java:617) @ javax.servlet.http.httpservlet.service(httpservlet.java:717) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:290) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ com.opensymphony.module.sitemesh.filter.pagefilter.parsepage(pagefilter.java:119) @ com.opensymphony.module.sitemesh.filter.pagefilter.dofilter(pagefilter.java:55) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:235) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:233) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:127) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:298) @ org.apache.coyote.http11.http11processor.process(http11processor.java:857) @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:588) @ org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:489) @ java.lang.thread.run(unknown source)
if remove javascript script, web page loaded succesfully. 1 can explain why ? think javascript doesn't work if using velocity template.
in velocity 1.7b1 new syntax #[[this included in output not parsed]]#
introduced:
#[[ $(document).ready(function() { ... }); ]]#
Comments
Post a Comment