velocity

How do I install and use Apache Velocity?

为君一笑 提交于 2019-12-12 10:54:09
问题 I have installed Apache server 2.4, and Ant 1.8.3, I have downloaded Velocity 1.7, and Velocity tools 2.0. I have read the installation documentation for Apache Velocity about ten times, and Googled it for two days, I still have no idea what to do with these files. Can anyone provide a detailed description on how to install Velocity please? I was hoping to develop using Eclipse, so I have also installed this. I would appreciate any assistance as I am stuck. Thank you. Update: I have

How to use Struts 2 with Velocity and Tiles

余生颓废 提交于 2019-12-12 10:44:48
问题 Has anyone been able to get velocity and tiles working with struts 2? I am having some problem finding examples or tutorials online and from what I have gathered from mailing lists it seems it might not even be possible at all (but the mails were quite old). 回答1: https://struts.apache.org/docs/tiles-plugin.html You can start with the documentation from apache struts. I am using tiles and velocity both and they are working fine. I am using velocity for the emailing templates and tiles for the

Can I convert an artifactId to a classname prefix in my maven archetype?

余生颓废 提交于 2019-12-12 08:20:11
问题 I'm creating a maven archetype and in the projects generated a want a class that is named after the artifact id of the generated project. The artifact id will be formatted like: the-project-name and the class should be named TheProjectNameMain . I've tried to do this in my archetype-metadata.xml but I can't get it right. <archetype-descriptor> <requiredProperties> <requiredProperty key="classNamePrefix"> <defaultValue>${WordUtils.capitalize(artifactId.replaceAll("-", " ")).replaceAll(" ", "")

org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'templates/email/test.vm'

不羁的心 提交于 2019-12-12 06:49:35
问题 My code as follow. VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "class"); ve.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); ve.init(); Template tempalte = ve.getTemplate("templates/email/test.vm"); I am getting following error. org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'templates/email/test.vm' at org.apache.velocity.runtime.resource

Liferay Dynamic Data Lists: How to get image URL?

时光毁灭记忆、已成空白 提交于 2019-12-12 04:37:38
问题 I am creating a custom template in velocity for a Dynamic Data Lists and I want to get the image URL for the selected image. How can I get it? The code is: #set ( $DDLRecordService = $serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService") ) #set ( $records = $DDLRecordService.getRecords($mathTool.toNumber($reserved_record_set_id)) ) #foreach ($record in $records) #set( $fields = $record.getFields() ) #set( $URL = $fields.get("URL").getValue() ) #set(

Binding a variable collection inside a Spring enabled Velocity template

房东的猫 提交于 2019-12-12 04:28:58
问题 Suppose I have the following form backing object for a Velocity 1.5 template: public class Bucket { String data1; String data2; String data3; String data4; // getters setters blah blah... } I'd like to bind these four String attributes to the following java.util.Map of Strings, inside four drop down single select controls: "a" : "1" "b" : "2" "c" : "3" "d" : "4" If inside my page's controller Model, I name the backing object "boData", and the value map "labelKeys", velocity can bind the

Change page title from Spring MVC Velocity view?

瘦欲@ 提交于 2019-12-12 04:05:47
问题 I feel like page title ought to be defined by the view rather than by a controller or model. In Zend Framework, I could write this in the view: $this->headTitle('Signup'); And that would change the page's window title to 'Signup'. How can I do that in Java Spring MVC using Velocity for the view? I thought maybe I could use something like: $page.setTitle("Signup") but it didn't work. This is probably similar to this question: https://stackoverflow.com/questions/18539645/how-to-set-head-meta

Java Velocity loop add div around every 3 items

戏子无情 提交于 2019-12-12 03:25:47
问题 I'm using the following foreach loop #foreach( $product in $allProducts ) <p>$product</p> #end to get <p>something</p> <p>something</p> <p>something</p> <p>something</p> <p>something</p> <p>something</p> Is it possible to wrap a div every 3 items in Velocity? For example to get the following result: <div> <p>something</p> <p>something</p> <p>something</p> </div> <div> <p>something</p> <p>something</p> <p>something</p> </div> I tried using #if ($velocityCount % 3 == 0) in the foreach loop but

Server goes into infinite loop while implementing Tiles with Velocity

爱⌒轻易说出口 提交于 2019-12-12 02:53:58
问题 EDIT: I am trying to integrate Tiles with Velocity using spring MVC. My server is going into infinite loop. The console reading of server is: I have marked the start of the loop as "-->". --> at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311) at org.apache.jsp.WEB_002dINF.views.layout_jsp._jspx_meth_tiles_005finsertAttribute_005f0(layout_jsp.java:102) at org.apache.jsp.WEB_002dINF.views.layout_jsp._jspService(layout_jsp.java:69) at org.apache.jasper.runtime

Breaking out of a foreach loop in Velocity

十年热恋 提交于 2019-12-12 01:12:27
问题 I am using #if( $velocityCount > 5 ) #break #end to break my foreach loop, but its not breaking instead it is printing #break in the output. I also tried: #foreach($item in $group.shipItems) #if( $velocityCount > 5 ) #item.break #end #end Here also it is printing #item.break instead of breaking the loop. 回答1: If you are using version 1.6, then #break should suffice. This makes me think you are using 1.4 or 1.5. Or are you seeing some errors? If you are using version 1.7, #break should still