Questions tagged [velocity-template-language]

Velocity Template Language - VTL

Apache Velocity first released in April 2001, is a Java-based template engine that provides a template language VTL to reference objects defined in Java code. It aims to ensure clean separation between the presentation tier and business tiers in a Web application (the model–view–controller design pattern).

It includes Variables, Properties, Methods, Directives, Macros, and more...

Official documentation.

33 questions
0
votes
0 answers

Iterate a map with VTL velocity template. Camel

I have a Map of this type but I have not been able to print it in a velocity template. This is for a SOAP service {DATOS_CONTACTO=[{TIPO_DOCUMENTO=CC, NUMERO_DOCUMENTO=1525250, COD_DEPARTAMENTO=10, COD_MUNICIPIO=222, DIR_RESIDENCIA=CL 4A 3 52,…
0
votes
1 answer

AWS AppSync access parent resolver properties in nested resolver (interpolation problem?)

I have a GraphQL API which works like this: mutation { customer(id: "123") { someMutation(new: "data") { id name email # from customer } } } We use nested resolver style because we have a large schema, and it helps keep things…
0
votes
1 answer

AWS API Gateway Mapping Templates - VTL complications with escaping for eventbridge

Brief: I have an API Gateway(V1-RestAPI) that sends events to EventBrdige on HTTP calls. I would like to put an event into EventBridge using the basic template of API Gateway - Method Request Passthrough in the following way: Entries: [{ Detail: {…
0
votes
0 answers

How to correctly escape JSON in AWS API gateway VLT mapping template?

I'm trying to publish an event to AWS Event Bridge via an API Gateway while transforming the event body using API gateway mapping templates written in Velocity Template Language (VLT) following this guide. The event body looks like this { …
0
votes
0 answers

How to covert number to words in velocity template?

I am using velocity template, I want to convert number to words, Is there any library present for that? eg: 99999999 = ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine
0
votes
1 answer

Number Formatting in Velocity Template upto atleast 2 decimal points

I have to format given character [132233.2453] like this -> 132,233.2453 current code -> $number.format("###,###.##00", $value) which seems to be working fine, but for character [295] -> it should be 295.00 [minimum 2 characters after decimal…
0
votes
1 answer

Unable to iterate json array in for each loop using velocity template

I have a json like this : { "name" : "xyz", "age" : "12", "familyprofile" : [{"name" :"abc", "Occupation":"manager","age":"30" },{"name" :"def","Occupation":"housewife","age":"30"}] } i am trying to print family profiles in table using velocity…
0
votes
2 answers

How to use nested if condition in velocity template template?

I'm trying to create a nested if condition using velocity template. I am not sure if it is right. Please give the suggestions if it works or not..!! #if(myExpression1) #if(myExpression2) Result 1 #else Result 2 #end #else Result 3 #end
0
votes
1 answer

What is the opposite of .contains for VTL?

I have the potential for two different outputs based on three additional attributes and the values they contain: #if($f3=="Banana" && $f2.contains("Mud")) This is gross #end Works just fine. However if I want to add in an #elseif to check for $f2…
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

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

How to transform array in json using velocity template for aws api gateway?

I've been working on writing velocity templates for aws api-gateway to transform the json response from my api to give a consistent response to the user. I've been trying to convert this json: { "amountCharges": [ "charge1", "charge2",…
0
votes
1 answer

If Else Construct with Comparison not Working In Velocity Template

I have below velocity template construct #if($no_of_entries > 1) Its True !! #else Its False !! #end Even when $no_of_entries is greater than 1 , say 10 , it prints Its False !! That means…
Atul
  • 1,560
  • 5
  • 30
  • 75
0
votes
2 answers

How to format currency number with proper positioning and fraction after decimals in Velocity template file?

I am using velocity template for generating pdf file. In this I have to show currency amount in the format like $ 7,242.84 or $ 0.00 or $ 410.70. I am using NumberTool class and in .vm file I am using something like…
Shashi Shekhar
  • 177
  • 1
  • 4
  • 16
0
votes
1 answer

Trigger Apache Velocity #set Parameter using a button (HTML / JS)

Is it possible to trigger a Velocity Template Language #set value to parameter via a button? I am trying to combine HTML, JS and Velocity doing the following: #set($ld=$pageParameters.Work_Item_Link_Direction.values)