velocity

How to access exception/stacktrace in Velocity template resolved by web.xml's error-page?

I would like to print the cause of the HTTP Error 500 on my Velocity template but am having difficulty figuring out how this can be done. My web.xml is configured with: <error-page> <error-code>500</error-code> <location>/error/500</location> </error-page> The location is backed by a Spring controller. The 500.vm page is resol...

Creating a form that doesn't map to an entity

Using spring MVC, how would I create a form that doesn't map to a entity (i.e. it has properties from multiple entities). I want to also validate and use their 'results' object that has the errors collection etc. Any online examples of this? I need to see it to understand it (newbie) ...

Calculate initial velocity to move a set distance with inertia

Hello, I want to move something a set distance. However in my system there is inertia/drag/negative accelaration. I'm using a simple calculation like this for it: v = oldV + ((targetV - oldV) * inertia) Applying that over a number of frames makes the movement 'ramp up' or decay, eg: v = 10 + ((0 - 10) * 0.25) = 7.5 // velocity chang...

Bind XMLGregorianCalendar field in Spring MVC with velocity

I have a model object with an XMLGregorianCalendar field. How can I bind it to an input field? For string fields I'm using: #springFormInput("model.object.stringfield" "") but can't work out the corresponding code for an XMLGregorianCalendar ...

Non-ascii characters in velocity templates are broken when displayed

Hi! I have non-ascii chars in velocity template files. And when processed they are garbled. The files are saved in UTF-8 encoding and response header contentType is also set to text/html;charset=UTF-8. What else can be done? ...

Is there a way to encode a URL in velocity template

Hi, Excuse my ignorance but I am new to Velocity and trying to fix someone else's problem. I need to encode a URL inside the velocity template. I create a url and as part of the query string I pass in a page name a user created. This page can contain special characters like ëðû. The url would look like http://foo.com/page1/jz?page=S...

Array merging/manipulation with Velocity

Hello, I have an array set inside a velocity template that contains some paths. The idea is to put a few "default" .js/.css files that 90% of the pages will use in this array. However, the other pages will still have to be able to add/delete values from this array, in case there are no linked files at all, or I need to add some. Given ...

Printing an additional label based on a condition in VTL

Hi guys , I have a doubt regarding VTL labels and if the below can be done and if yes, how - I have a general label which goes on like ^XA .... //calls a macro// //Based on reply from macro #parse(another zpl file to be printed as an additional label after the current zpl file is printed ) ... ^XZ So, based on the reply it parses ...

How can I get Velocity to output a greater than / less than without escaping it?

I'm trying to get Velocity to output the following Javascript code: if ((whichOne+1) <= numCallouts ) { whichOne = whichOne + 1; } else { whichOne = 1; } Whenever I try to get Velocity to print a > or a <, it represents it as a & gt; or & lt;, which doesn't help me since I'm trying to get it to produce Javascript. I've tried: #s...

Freemarker/Velocity - date manipulation

Hello, I have a fairly simple question about these 2 templating engines. I'm trying to make a future/paste date, a fixed time from now, e.g. 18 months ago, or tomorrow. I know that it is possible to do this with a java date object inside a velocity/freemarker template (something like $date.add(2,-18)), but I would like to do this with D...

Unable to instantiate VelocityEngine, when deploying war file

Hi, I am deploying an application on Tomcat 6, using a war file. I've compiled the source code given by the vendor on the same machine, then moved the war file to {tomcat-home}/webapps/ When I start up the application, I see a error message: The SystemInformationService could not be retrieved from the container. Therefore very limit...

List in velocity macro, cannot find contains method

I put a list strings as validTypes in velocity. When I do : #if (${validTypes}.contains("aaa")) // do something #end it throws an error. But when I do : #foreach (${validType} in ${validTypes}) ${validType} #end it works fine. Do I need to use velocity tools for this? How do I use it in an eclipse plugin? Are there any work ar...

How to escape trailing backslash in NVelocity

I am using NVelocity to process various PowerShell scripts before they are executed against a server. My question is how to escape a backslash trailing a variable: e.g. ls \\$computername\c$ $computername should be replaced with a valid computer name at runtime, but the trailing backslash (\c$) means that it does not. Thanks Ben ...

Core Location and speed measurements

Does anyone know if Core Location in the iPhone OS uses anything but simple vector math to calculate speed? I've read that the GPS system can provide speed measurements that can be accurate when position is not (I believe using the Doppler shifts of the signals). I've tried and failed to see if the iPhone does this. The question is basi...

NVelocity (or Velocity) as a stand-alone formula evaluator

I am using NVelocity in my application to generate html emails. My application has an event-driven model, where saving and/or updating of objects causes these emails to be sent out. Each event can trigger zero, one or multiple multiple emails. I want to be able to configure which emails get sent out at run-time without having to modify...

Loading velocity template inside a jar file

I have a project where I want to load a velocity template to complete it with parameters. The whole application is packaged as a jar file. What I initially thought of doing was this: VelocityEngine ve = new VelocityEngine(); URL url = this.getClass().getResource("/templates/"); File file = new File(url.getFile()); ve = new V...

session scope in velocity

how can i use session scope in VELOCITY(in view part am using sample.vm like that)... my requirement is when i login into a page,i want to store the user's name& some details in session and if i press logout i want to clear all the information in that session. thanks for ur help ...

Velocity template dynamic reference value modification from Java code

I need to replace references (properties and methods) in the Velocity templates to some other values during template rendering. For example, from the template below: ___ I have $some text $daisy #foreach ($someElement in $someCollection) #$someElement.doSomething() #end ___ I need to get such text: ___ I have lalala1 text lalala1 l...

Working/Include Direct of a Servlet

Hi there, I'm currently starting to learn to use java to create dynamic websites. I've started using a servlet and the template engine 'velocity'. My Environement: WebContent/ WEB-INF/ gallery/ template.file My Question: I want to use the "template.file" as template. WHAT filename/path do I have to enter to reach m...

Set does not work in velocity

Looks like set does not work in velocity when written as below : #set (${modifier} = "some") It works if I do #set ($modifier = "some"). Any reason for this? EDIT : It doesn't work means no variable is set. ...