Questions tagged [apache-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 permits anyone to use a simple yet powerful template language to reference objects defined in Java code.

Velocity 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).

It include 2 releases of Engine and Tools:

Latest Engine 2.0 released in 2017-08-06

Latest Tools 2.0 released in 2010-05-10

Site http://velocity.apache.org/

74 questions
491
votes
10 answers

What is a classpath and how do I set it?

I was just reading this line: The first thing the format() method does is load a Velocity template from the classpath named output.vm Please explain what was meant by classpath in this context, and how I should set the classpath.
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
9
votes
1 answer

How to check if value exists in an array using Velocity Template Language

I am not sure how I could achieve the following using Velocity Template Language. Essentially, I'd like to check if a given value exists from the given list/array. In C#, it's equivalent to .Any() or .Contains() method. #set($myValues = ["apple",…
woodykiddy
  • 6,074
  • 16
  • 59
  • 100
9
votes
2 answers

AppSync GraphQL mutation server logic in resolvers

I am having issues finding good sources for / figuring out how to correctly add server-side validation to my AppSync GraphQL mutations. In essence I used AWS dashboard to define my AppSync schema, hence had DynamoDB tables created for me, plus some…
Ilja
  • 44,142
  • 92
  • 275
  • 498
5
votes
2 answers

Query DynamoDB with multiple begins_with clause in AppSync

I'm currently trying to create a dynamic query using AppSync and Apache Velocity Template Language (VTL). I want to evaluate series of begins_with with "OR" Such as: { "operation": "Query", "query": { "expression": "pk = :pk and…
Jose A
  • 10,053
  • 11
  • 75
  • 108
4
votes
1 answer

Apache Velocity: remove key/value from json

I have a JSON { "Id": "xxx", "Type": "Transaction.Create", "Payload": { "result": 2, "description": "Pending", "body": { "redirect": { "url": "xxx", "fields": { …
DenCowboy
  • 13,884
  • 38
  • 114
  • 210
4
votes
2 answers

Create JSON Object with Velocity Template Language

I am working with the Apache Velocity Template Language (VTL) in AWS AppSync. In my request template I query an undefined amount of items with different elements. What I want to do in the response template is to transform the result into a JSON…
benra
  • 386
  • 1
  • 4
  • 18
3
votes
0 answers

code style for velocity template files in IntelliJ

Problem The automatic indents in .vm files don't behave as I want them to. Below I add the auto formatted file and also the formatting I want. The following code snippet is auto formatted by…
3
votes
1 answer

append for string variable in Apache Velocity Template Language

I want to construct query string in the API Gateway mapping template. I have something like this #foreach($entry in $entries) #set($count = $foreach.count) #set($entriesQueryString = "$!{entriesQueryString}Id=${count}&" #end The idea is to…
Tigran Sahakyan
  • 363
  • 1
  • 5
  • 10
3
votes
1 answer

How to manipulate strings and array in Apache Velocity request mapping template in AWS appSync

This is my first time working with VTL, so please correct my code if there is something very silly in it. What I want to achieve { "cities": ["jaipur", "mumbai", "delhi", "sheros", "jalandhar", "bengaluru"] } Graphql schema: type Query{ …
3
votes
1 answer

How to convert object to JSON in AWS API Gateway?

I have some simple data I want to transform with API Gateway: { "data": [ {"id":"1", "name":"Foo"}, {"id":"2", "name":"Bar"}, {"id":"3", "name":"Dead"}, {"id":"4", "name":"Beef"} ] } I'm able to loop the…
3
votes
1 answer

API Gateway Mapping Template optional field

I've been working with Mapping Templates on AWS API Gateway, in particular for DynamoDB integration. And I found very inconvenient to check against optional fields. For example I have a JSON payload like this: { "optional_field": "abcd" } now…
3
votes
2 answers

Using Apache Velocity (with SparkJava) with loaded templates

I am building a website using Spark + Velocity. This has HTML components that are very similar across the webpages of the site, so I have put my shared components in some templates that I dynamically load into the page. To give you a simple example,…
crazyGuy
  • 338
  • 2
  • 15
2
votes
1 answer

Velocity upgrade from 1.7 to 2.0

I am trying to migrate from velocity 1.7 where I use LogChute interface. In my current implementation I have used the log method to get the velocity log level and comparing our own log level. Please see the code below. @Override public void log(int…
2
votes
0 answers

ConcurrentModificationException in Apache Velocity 1.7 with Java 8 and Ant 1.9

We have upgraded our project from java 7 and ant 1.8 to java 8 and ant 1.9. In java 7, we were able to use apache velocity 1.7 without any issues. However after upgrading to java 8, we get ConcurrentModificationException. Caused by:…
KRR
  • 43
  • 5
2
votes
1 answer

Remove certain element from array in Velocity Template Language (VTL)

I would like to remove a certain element from an array in Velocity Template Language. I did not find any appropriate method looking through the documentation of Apache VTL, that's why I am asking here for help. I have tried following (.remove()…
1
2 3 4 5