velocity

Completely overwriting a file with Velocity / NVelocity

I am trying to use NVelocity templates in a .Net application: using a template to output results to a file. It all seems to work fine except for the fact that the output is never fully overwritten. If my file is 100 characters long and the template only renders 20 characters, the last 80 characters are never altered! Code sample: Fi...

Where should I put Velocity template files for a command line utility built with Maven?

I have a small command line utility project that I'm using Maven to manage. The utility is a very simple app to populate a Velocity template and dump the results to a new file. My problem is where to put my Velocity templates. When I put them in src/test/resources/foo/bar/baz, mvn test fails because it can't find the referenced template,...

How to access static members in a Velocity template?

I'm not sure if there is a way to do this in Velocity or not: I have a User POJO which a property named Status, which looks like an enum (but it is not, since I am stuck on Java 1.4), the definition looks something like this: public class User { // default status to User private Status status = Status.USER; public void s...

Velocity and ignoring java method return

I want to add an element to the list in my Velocity macro. Is this only way to avoid 'true' text appearing to the Velocity output? #set($path = []) #set($swallow = "a") #set ($swallow = $path.add("blaablaa")) ...

Velocity and JavaScript

Hi, I have a bit of a problem here: #foreach($image in $command.lessonLearned.images) Image: $image.fileName <input type="submit" onclick="submitForm();setImageToRemove($image.id);setAction('removeImage');" value="REMOVE"/><br/> #end $image.id inside the onclick event is not evaluated as a velocity variable. How do I make it w...

Database framework developing

Hello everyone, I'm developing (another) java web framework for personal use, and in addition to that I also want to develop somekind of persistence framework. I have already developed and engine that in order to access the table, you must only extend a class and create your fields with the same type and name of those in the table. Ex:...

How to print stack trace of an exception in a velocity template

How to print the complete stack trace of the exception using a velocity template My present template has $exception as template variable, which contains the exception. ...

Velocity named parameters for a macro

I have a macro taking several parameters. Some of these are optional and if a parameter is left empty it will replaced with default. Now the question is how to make this as easy as possible for ordinary web designer. Is there any other possibity apart from my examples to handle this case? Example 1: The obvious problem here is the op...

A Java Server side (Jsp, velocity, whatever) Calendar component?

Do you know of a Java Server side calendar component. Not a date picker, but a way to display months or weeks as in google calendar with events from my db. ...

JSP vs Velocity what is better?

What is better between JSP and velocity in - Performance - Ease of use - Ease of creating reusable components - Availability of open source 3rd parties - IDE support ...

Client side object velocity

I would like to create an object client side and add it to another object. I'm using velocity and Spring. I form a command object and pass it to the view as a backing object. I want to create and add a new object to this command object without saving either object to the db. The reason for this is that I want to have some persistence...

Unsetting a variable in Velocity

Is it possible to set a Velocity reference to 'null' or 'undefined'? The Velocity template language reference says #set - Establishes the value of a reference Format: # [ { ] set [ } ] ( $ref = [ ", ' ]arg[ ", ' ] ) Usage: $ref - The LHS of the assignment must be a variable reference or a property reference. ...

How do I create a velocity template that outputs two '#' litterals at the beginning of the line?

I need to create a velocity document that has some lines prefixed with ¨## Foo", but since the # is the velocity directive command, it is not working for me. What I want my output document to look like: ## Foo this ## Bar that k1, v1 k2, v2 k3, v3 Escaping has not worked out how I expected. The below does not work, obviously, as the...

How to get data from the velocity page in a action class?

How to get data from the velocity page in a action class? ...

Which Java HTML templating technology works in a way that is closest to Ruby (erb/haml)?

Among the Java templating solutions such as Apache Velocity, Freemarker, Hamlets, Tapestry, StringTemplate, JSP, JSP Weaver (others?) which would most closely approximate the conciseness and simplicity of similar HTML templating solutions in Ruby - haml/erb. I'm concerned both with the syntax of the templating engine as well as how simpl...

Implementing Login Velocity Checks

I need to implement login velocity checking for a web service. The service is in ruby and the database is MySql. I can imagine bad ways to do this. For example, have a table that stores every login attempt's time and whether or not it was successful, and every time the user tries to log in, query that table for the last n login attemp...

Error in velocity and log4J

Hello, I built a webapp that works perfectly fine in my localhost (tomcat). But when I tried to deploy, velocity crashes in init(), leaving me with this strange stack trace here (sorry for the size): ERROR [main] (VelocityConfigurator.java:62) - Error initializing Velocity! org.apache.velocity.exception.VelocityException: Failed to i...

How to protect a velocity template from tampering?

We have a Velocity template for a receipt. The template includes the Tax Identification Number, the value of which will be substituted at the time of receipt generation. This is to ensure the TIN of the real license holder is printed on the receipt. How can we prevent the end user from hardcoding the TIN number in the template itself? I...

JSF renderers - using templates

I was wondering if anyone has experience with using some kind of templating language for generating the html output in the component's renderer. It seems to me that doing stuff like the following is difficult to maintain if your component rendering will suffer changes during its life. writer.write('\n'); writer.startElement("script",...

Is there an Apache Velocity plugin for Netbeans 6.5 or higher?

I'm looking for a plugin similar to the Eclipse plugins Veloeclipse or Velocity Web Edit for NetBeans. Update: I tried the Velocity Editor Support plugin mentioned by Kathy Van Stone (thanks!), but it's not quite as robust as I had hoped. It doesn't support code folding, directive tag matching, or code completion, as far as I can tell....