velocity

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" );

Maven archetype required property number

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 22:44:02
问题 I have a Maven archtype that use a requiredProperty that contains a number, but the velocity variable are string. So, in my template I can't test if this property is greater than a number: #if( $myVar gt 5 ) I have tested the following solution without success. I've also tried this: #set( $intVar = Integer.parseInt($myVar) ) That's also fail at the archetype generation. Any advice? 回答1: You can't reference classes from Velociy, so Integer.parseInt won't work. However, since in Java any static

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

Velocity syntax highlighting in WebStorm

喜你入骨 提交于 2019-12-10 18:24:00
问题 Is there a plugin/download for Velocity syntax in WebStorm? I came across this post but do not have the dir filetypes in my path (for Mac). I'd like some syntax highlighting for easier reading if it's available: 回答1: Velocity support in only available IntellJ IDEA Ultimate. Unfortunately migrating it to WebStorm is not an easy task, as Velocity plugin heavily relies on Java... So currently we have no plans to provide Freemarker/Velocity template engine support in WebStorm. If you miss this

Maven archetype + Velocity: how to show the date

a 夏天 提交于 2019-12-10 17:33:25
问题 I have a maven archetype project. When I use this archetype I want that some files report the actual date. I tried with $date but Velocity does not recognize it. I found something called DateTools but I don't know how can I use it. It's the first time I use Velocity. 回答1: Unfortunately, the Maven Archetype plugin doesn't come bundled with Velocity Tools. I've added it by modifying the Maven Archetypes Plugin. Follow these steps, presuming you're using Maven 2.2.1: svn co -q http://svn.apache

speed or acceleration of motion event android

老子叫甜甜 提交于 2019-12-10 17:32:22
问题 Is it possible to get the speed or velocity or acceleration of touch event in android with the existing api? I have gone through MotionEvent class and none of the fields in that class seem to retrieve information that i need. Any help would be greatly appreciated 回答1: MotionEvent does not help you in this case. You can use VelocityTracker class. It gets MotionEvent instances and calculates velocity of recent touch events. You can take a look at its documentation here: http://developer.android

Reading model objects mapped in Velocity Templates

人盡茶涼 提交于 2019-12-10 16:11:29
问题 I have a Struts + Velocity structure like for example, a Person class, whose one property is a Car object (with its own getter/setter methods) and it is mapped to a Velocity form that submits to an Action, using ModelDriven and getModel structure. I what to put a button on the form that shows "View Car" if car property is not null or car.id != 0 or show another button "Choose Car" if car is null or car.id = 0. How do I code this. I tried something like that in the template file: #if($car !=

Velocity + Spring

半城伤御伤魂 提交于 2019-12-10 16:03:06
问题 I am attempting to setup a webapp with the above components. I've jumped all but the last hurdle which is integrating Spring & Velocity Tools. I saw this post this morning, and updated it with a slightly different answer than what was provided. However, once I attempted to add in ParameterTool to one of my templates like so: #foreach( $key in $params.keySet() ) $key = $params.getValue($key) <br /> #end I receive a NPE java.lang.UnsupportedOperationException: Request is null. ParameterTool

How to test API Gateway methods with custom authorizer and empty $context.authorizer.* variables?

有些话、适合烂在心里 提交于 2019-12-10 13:35:20
问题 I have an API Gateway with a POST method that puts directly to a DynamoDB table. My method is also configured to use a custom authorizer via Lambda. In my template mapping I'm consuming some of the authorizer variables, such as $context.authorizer.principalId or $context.authorizer.accountId . Simplified template mapping looks as follows: { "TableName": "$stageVariables.tableName", "Item": { "AccountId": { "S": "$context.authorizer.accountId" }, "Id": { "S": "$context.requestId" }, "Content":

Checking if a string contains a particular substring in Velocity

不打扰是莪最后的温柔 提交于 2019-12-10 12:34:12
问题 In Velocity I have a variable called $url which contains the following string: [ContentId(2.7507), ContentId(2.7508), ContentId(1.44551)] I want to check if that string contains the substring 1.44551. This is the code I've written so far, but for some reason it's returning False: #if($url.contains("1.44551")) <p>The article content id is 1.44551</p> #else <p>The article content id isn't 1.44551</p> #end I would expect this to be returning True, as the 1.44551 substring is present in the $url