Questions tagged [velocity]

Apache Velocity is a Java-based template engine. It can be used to dynamically generate web pages, email messages, source code, or any other text file.

Apache Velocity is a Java-based template engine. It can be used to dynamically generate web pages, email messages, source code, or any other text file.

Apache Velocity is a project of the Apache Software Foundations (ASF).

More information is available at the project home page: http://velocity.apache.org.

From the developer perspective, the fundamental pattern for rendering a text file is:

  • Create and initialize a VelocityEngine.
  • Add your data objects to a Context (essentially, a map of objects available for use in the template)
  • Choose a template
  • Merge the template with the context.

This can be done in a few lines of Java code, or you can use one of several frameworks to integrate this with your application.

One of the most popular web application frameworks which integrates Velocity is the Spring Framework. For simple servlet based applications, most developers use one of the Velocity Tools servlets (also available from the Apache Velocity project).

Useful Online Resources

  1. Velocity User Guide
  2. Velocity Developer Guide
2370 questions
0
votes
2 answers

velocity template loop through array to create string

I'm trying to use the velocity templating language in an AWS appsync resolver to create a string by looping through an array of characters. Given the array listOfWords = ["好" "克力"] how would I achieve the string output of queryString = "+\"好\"…
hyprstack
  • 4,043
  • 6
  • 46
  • 89
0
votes
0 answers

How can I use emoji characters in a Velocity Template

I am trying to use emoji characters in my velocity templates. The templates are being read into a Java string using Template template = getVelocityEngine().getTemplate(templateRef, "UTF-8"); VelocityContext context = new VelocityContext();…
Ken Joyner
  • 921
  • 9
  • 14
0
votes
2 answers

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…
SlyRax
0
votes
1 answer

Veocity : How to find frequency of values in array and then sort the values in the order of frequency

I have any array in velocity which has duplicate values too. I want to create an array with unique values where all the values are sorted based on their count/frequency in the original array. For example: #set($y = 0) …
Kaps
  • 23
  • 7
0
votes
1 answer

Velocity Template - Show and Hide

I have the following velocity template. Address 1* : $currentAddressAddress1 #if ($currentAddressAddress2) Address 2 : $!currentAddressAddress2
Dev
  • 21
  • 1
  • 6
0
votes
1 answer

Regex replaceAll not working on Velocity Template

It seems that this code is not wokring on velocity template, #foreach ($req in $Project.Requirements) { #set($brRegex = "<[^>]*>") #set ($sr = $req.StatedRequirement.replaceAll($brRegex, " ")) …
bherto39
  • 1,516
  • 3
  • 14
  • 29
0
votes
1 answer

Chipmunk 2D Setting Oribital Velocity Function

So I've used the Planet.c demo to set up a velocity function for my 2D iPhone game that's in the works that involved orbiting planets. However the following code sets up nice orbits but only does so around the origin of the screen i.e. the lower…
Primus202
  • 648
  • 7
  • 24
0
votes
0 answers

Use Apache velocity 1.7 or 2.0 in Java application without Maven

Can someone detail the steps to use the Velocity templating engine in Java plugin project without using Maven for building and resolving dependencies. I would like to download the required plugins/dependencies manually and package them part of my…
Rookie
  • 33
  • 5
0
votes
1 answer

Multiple #if statements in Apache Velocity

I want to write the following if - else logic in Velocity If $var1 == NONE ( If $subvar1 != 'null' return True else return Failed_Sub1) Else If $subvar2 != 'null' return True else return…
Chris T
  • 155
  • 1
  • 11
0
votes
1 answer

javascript code execution problem at velocity response writer in SOLR

I have noticed that velocity response writer templates do not run JavaScript codes in SOLR anymore. Although all html and css codes are rendered, the javascript code below is not executed and display "Result" at browser,
0
votes
1 answer

Removing brackets from velocity template (xml escaping)

I am new to velocity template. I am using velocity template to parse the data in xml format. Using below code to fetch userId: $esc.xml("$!userDetails.userId).replaceAll("&#[0-9a-fA-F]+;","") Generated output: [ABC123] Excepted output: ABC123 Can…
0
votes
1 answer

Every velocity tool escape function working except url()?

I can get $esc.html to work, but not $esc.url, it just comes up literal even though I follow example at: http://velocity.apache.org/tools/devel/generic/EscapeTool.html Interestingly enough, on that page the url() section's head is "$attrib.name"…
legir
  • 1
0
votes
1 answer

Jira java variable inside velocity in javascript

I am developing jira and using variables in velocity, which are exposed as public getters in java plugin code. Everything seems good, I am getting my java code results in output.vm inside velocity template after processing excel file but I would…
jira jira
  • 17
  • 6
0
votes
1 answer

javascript sleep on function which is not called

I have this simple js in velocity jira template. I need to sleep function and call function test but its not called at all. Can you elaborate into this issue why its not happening? issueNumber is velocity variable.