vtl

How to add Current Date in putItem in VTL

瘦欲@ 提交于 2019-12-11 10:33:08
问题 { "version": "2017-02-28", "operation": "PutItem", "key": { "id": $util.dynamodb.toDynamoDBJson($util.autoId()), "createdDate":$core_v2_utility.CurrentDate }, "attributeValues": $util.dynamodb.toMapValuesJson($ctx.args.input), "condition": { "expression": "attribute_not_exists(#id)", "expressionNames": { "#id": "id", "#createdDate":"createdDate", }, }, } I have been trying to add a createDate into DynamoDB using VTL.I am finding error with $core_v2_utility.CurrentDate 回答1: AWS AppSync does

Reference a Map by name within Velocity Template

别说谁变了你拦得住时间么 提交于 2019-12-11 03:14:12
问题 Pretty sure there is an easy answer to this, but just can't find the right VTL syntax. In my context I'm passing a Map which contains other Maps. I'd like to reference these inner maps by name and assign them within my template. The inner maps are constructed by different parts of the app, and then added to the context by way of example public static void main( String[] args ) throws Exception { VelocityEngine ve = new VelocityEngine(); ve.init(); Template t = ve.getTemplate( "test.vm" );

Adding to List Prints true in Velocity

。_饼干妹妹 提交于 2019-12-10 22:15:14
问题 I am trying to add some string values to a list in Velocity. When I run the code it works alright. But the line where it adds the value prints true. Is it always like that in Velocity? I am new to Velocity templates, so cant figure it out myself. #set ($uniqueInterfaces = []) #if($ipv4interfaceName == $ipv6interfaceName) $uniqueInterfaces.add($ipv4interfaceName) #end Its part of larger code with a nested foreach. It has two matches in it, so the output is: true true I do not need this true

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

泪湿孤枕 提交于 2019-12-10 02:19:01
问题 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 this kind of thing possible with VTL (Velocity Template Language)? 回答1: I had not found any yet. The closest I can get is to hack a logging framework to print

Velocity (VM) template request parameters: Getting GET variables

。_饼干妹妹 提交于 2019-12-08 09:31:12
问题 How do i access GET variables as passed in the URI in a VM template? This works only when loading the widget URL: $request.get("parameters").get("fav").get(0) I'm looking for a neat solution that works with friendly URLs. Here's my testing template: <br><br><br> #set($url = $request.attributes.CURRENT_URL) <h2>url: $url</h2> #set($favs = $url.split("fav=")) favs: $favs<br> favs.size(): $favs.size() <br> #if($favs.size() > 1) #set($fav1 = $favs.get(1).split("&").get(0)) fav1: $fav1<br> #else

How to send custom error in AppSync with $util.error

非 Y 不嫁゛ 提交于 2019-12-08 07:37:33
问题 I have a question about AppSync error handling. I would like to send errorInfo object along with the error response and I tried with $util.error . Per the document: https://docs.aws.amazon.com/appsync/latest/devguide/resolver-util-reference.html $util.error(String, String, Object, Object) Throws a custom error. This can be used in request or response mapping templates if the template detects an error with the request or with the invocation result. Additionally, an errorType field, a data

How to throw an user-defined exception from Velocity Template Script (VTL)?

二次信任 提交于 2019-12-07 07:46:18
问题 How to throw an user-defined exception from Velocity Template Script (VTL) ? From my velocity script, i need to throw an exception based on a condition, so that the caller can catch the exception and present an useful error messages to the end user. For Example. #if($passwordfield1 != $passwordfield2) throw an exception here #elseif($passwordfield1 == $passwordfield2) do something #end In the above example, if passwordfield1 and passwordfield2 is not matching,an appropriate exception should

Velocity (VM) template request parameters: Getting GET variables

此生再无相见时 提交于 2019-12-06 16:14:27
How do i access GET variables as passed in the URI in a VM template? This works only when loading the widget URL: $request.get("parameters").get("fav").get(0) I'm looking for a neat solution that works with friendly URLs. Here's my testing template: <br><br><br> #set($url = $request.attributes.CURRENT_URL) <h2>url: $url</h2> #set($favs = $url.split("fav=")) favs: $favs<br> favs.size(): $favs.size() <br> #if($favs.size() > 1) #set($fav1 = $favs.get(1).split("&").get(0)) fav1: $fav1<br> #else No fav! #end #if($favs.size() > 2) #set($fav2 = $favs.get(2).split("&").get(0)) fav2: $fav2<br> #end

How to throw an user-defined exception from Velocity Template Script (VTL)?

↘锁芯ラ 提交于 2019-12-05 09:31:49
How to throw an user-defined exception from Velocity Template Script (VTL) ? From my velocity script, i need to throw an exception based on a condition, so that the caller can catch the exception and present an useful error messages to the end user. For Example. #if($passwordfield1 != $passwordfield2) throw an exception here #elseif($passwordfield1 == $passwordfield2) do something #end In the above example, if passwordfield1 and passwordfield2 is not matching,an appropriate exception should be thrown and that needs to be propagated to the end-user. Is there any way to achieve this from

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

 ̄綄美尐妖づ 提交于 2019-12-05 01:19:14
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 this kind of thing possible with VTL (Velocity Template Language)? I had not found any yet. The closest I can get is to hack a logging framework to print out information that you want. What you do is: create an class with logging method which return boolean