velocity

How I hide empty Velocity variable names ?

I am using Struts + Velocity in a Java application, but after I submit a form, the confirmation page (Velocity template) shows the variable names instead an empty label, like the Age in following example: Name: Fernando Age: {person.age} Sex: Male I would like to know how to hide it! ...

Reading model objects mapped in Velocity Templates

Hello, I have a Struts + Velocity structure like for example, a Person class, whose one property is a Car object (with its own getter/setter methods) and it is mapped to a Velocity form that submits to an Action, using ModelDriven and getModel structure. I what to put a button on the form that shows "View Car" if car property is not nu...

Template Engines for Spring Framework

I've taken quite a shine to the Spring Framework and would like to get into it a bit more. I have noticed that aside from plain vanilla JSPs there are various template engines for use with Spring MVC, such as Velocity and Freemarker. Are there others? Which one do you recommend? ...

How to escape a # in velocity

I would like to know how can i escape a # in velocity. Backslash seems to escape it but it prints itself as well This: \#\# prints: \#\# I would like: ## ...

What causes a velocity Template.merge() failure? How does one avoid it?

Hello, Our team has been experiencing a recurring problem with velocity templates. Upon rendering, some throw a RuntimeException with the message "Template.merge() failure - Unable to render Velocity Template, '/template.vm'". We have not been able to reproduce the problem and the documentation on the web is pretty insufficient. The pro...

Is there a way to debug Velocity templates in the traditional code debugging sense?

We make heavy use of Velocity in our web application. While it is easy to debug the Java side of things and ensure the Velocity Context is populated correctly, it would be extremely valuable to be able to step through the parsing of the VTL on the merge step, set breakpoints, etc. Are there any tools or IDEs/IDE plugins that would make...

Accessing constant values from an Apache Velocity template?

Is it possible to access a constant value (i.e. a public static final variable defined in a Java class) from a Velocity template? I would like to be able to write something like this: #if ($a lt Long.MAX_VALUE) but this is apparently not the right syntax. ...

How do I create a custom directive for Apache Velocity

I am using Apache's Velocity templating engine, and I would like to create a custom Directive. That is, I want to be able to write "#doMyThing()" and have it invoke some java code I wrote in order to generate the text. I know that I can register a custom directive by adding a line userdirective=my.package.here.MyDirectiveName to my v...

Template-Engine for Struts

Freemarker, Tiles oder Velocity? Which template engine is the best for a multi-user-system build with struts? ...

Suggestions for a Java-based templating engine?

Do you know a better template engine than FreeMaker or Velocity? ...

tiles in struts project - better than freemarker?

I want to use a template engine in a struts application and would like to know if using TILES can be recommended instead of FREEMARKER or VELOCITY. ...

What is the best way to access an array inside Velocity?

I have a Java array such as: String[] arr = new String[] {"123","doc","projectReport.doc"}; In my opinion the natural way to access would be: #set($att_id = $arr[0]) #set($att_type = $arr[1]) #set($att_name = $arr[2]) But that it is not working. I have come with this workaround. But it a bit too much code for such an easy task...

Velocity #parse but assign it to a variable

Say you have a standard template with included (parsed) header, body, footer templates. In the body template a variable like $subject is defined and you want that also displayed in the header template. In some other template languages like HTML::Mason(perl based) you would evaluate the body template first to pick up the $subject variab...

Struts 2 + tiles + velocity interoperability?

Has anyone been able to get velocity + tiles working with struts 2? I am having some problem finding examples or tutorials online and from what I have gathered from mailing lists it seems it might not even be possible at all (but the mails were quite old). ...

How many projects you know uses Velocity framework

Do you have idea how many sucessful projects used Velocity framework for developing their UI ?.The reason I am asking is Velocity is replaced in most of the cases by JSP tags, but in our product we still use Velocity frmaework. ...

Velocity: $display.list() and a collection of objects.

Velocity DisplayTool has a useful method: $display.list($list) That will format a collection or array into the form "A, B and C". The problem is lets say I have an ArrayList of objects, how do I output a specific object field instead of the whole object? For example the regular loop would look like this: #foreach($obj in $list) ...

How to insert Header and Footer in .vm file

I have a .vm (Velocity) file which is run to generate a DOC file. I want to have a very simple header and footer in this resultant DOC file. How can I write code in .vm file for this. I do not want to include header and footer files as external files. I want simple code in the same .vm file. Please help!!! ...

Configure velocity to render an object with something other than toString?

Is there a way to configure Velocity to use something other than toString() to convert an object to a string in a template? For example, suppose I'm using a simple date class with a format() method, and I use the same format every time. If all of my velocity code looks like this: $someDate.format('M-D-yyyy') is there some configuratio...

Benefits of using JSTL vs Velocity for view layer in MVC app?

I'm currently building a Spring MVC application. I was looking to use JSP pages with tag libraries for handling the view layer and formatting of the HTML, but I've come across another group in my company that uses Velocity templates for the same purpose. From what I can see, it seems to me as if there are a lot of similarities between t...

Velocity editor plugin for Eclipse?

I've seen Veloedit, which seems to have good syntax highlighting but doesn't allow tab characters in the file being edited (wtf?) and also has no understanding of HTML. With a little bit of googling I've found Veloecipse, which claims to build upon Veloedit and also add HTML support - but doesn't seem to be compatible with Eclipse 3.4. ...