velocity

Velocity - random number generation in a template

女生的网名这么多〃 提交于 2019-12-25 03:28:34
问题 I'd like to assign a random value to a variable in a velocity template. However, #set ($random = $math.getRandom()) returns: java.util.Random@5706937e. How to obtain this value or assign a random value to a variable in a different way from within a velocity template? 回答1: #set ($random = $math.getRandom()) use velocity 1.7 from this link enter link description here and in vm file use #set($mathTool = $serviceLocator.findService("org.apache.velocity.tools.generic.MathTool")) //range: 1 - 20

How do I get HTML rendered in creating email message with velocity?

久未见 提交于 2019-12-25 03:07:09
问题 I use velocity to create a string writer, then merge that into a template. The template #includes html to make a simple table, yet only the raw HTML shows up in the email... it does not get rendered. Email is being sent from Google server to outlook client. Can anyone tell me How can I get rendered HTML into an email message created with Velocity? Thanks! 回答1: You have to set a Content-type: text/html header. Appart from that, you have to be aware that all the different email clients may

How velocity impacts on CCSprite in Cocos2d Chipmunk?

浪子不回头ぞ 提交于 2019-12-24 14:05:04
问题 I am in need of the basic understanding of how velocity changing works? i.e. how CCSprite is able to jump at particular height when some velocity is set? Let me give you an example on which I am working currently. I am preparing a demo like flappy bird, in which I wanted my bird to land on vertical pipes. So, it is like, my birdy jumps from the pipe to another pipe :smile:. Check the gif I place here: https://www.dropbox.com/s/n46vak6qy5wu4x4/jumpyBall_15_jul_152.gif?dl=0 I am using Sprite

Configure velocity to render an object with something other than toString?

回眸只為那壹抹淺笑 提交于 2019-12-24 10:39:37
问题 Is there a way to configure Velocity to use something other than toString() to convert an object to a string in a template? For example, suppose I'm using a simple date class with a format() method, and I use the same format every time. If all of my velocity code looks like this: $someDate.format('M-D-yyyy') is there some configuration I could add that would let me just say $someDate instead? (Assuming I'm not in a position to just edit the date class and give it an appropriate toString()). I

How do I check for documents with more than 1 Tag in xwiki?

断了今生、忘了曾经 提交于 2019-12-24 09:41:37
问题 So I want to access all the documents that are tagged using 2 tags instead of one. For example I want all photoshop tutorial documents.If I searched with the tag tutorial I would get other software tutorials too and if I use the tag photoshop i get all documents and not just the tutorials. I should be able to provide 2 tags and get documents which are tagged with both these tags. Right now this is what I did, #set ($list = $wiki.tag.getDocuments($tag)) #set ($list2 = $list.getDocuments($tag2)

Parse string into JSON

只谈情不闲聊 提交于 2019-12-24 07:28:41
问题 I have an array of objects $arr and an object has a property named as jsonData which contains json data in a string, how to parse that string to actual JSON object and retrieve lets say value for key name ? I tried this: #foreach ($obj in $arr) #set ($jsonData = "#evaluate(${obj.jsonData})") $jsonData.get("name") ## <-- not working #end 回答1: If anyone using velocity in AWS API Gateway ends up here, you can use AWS' $util.parseJson() to covert a string to JSON. Make sure you note if your

Apache Velocity access String array created in Java code?

回眸只為那壹抹淺笑 提交于 2019-12-24 01:01:48
问题 I am trying to access a String array which i have created in my Java class. The string array is stored in a Map with the name 'notSelected' using the same key. I also have a single String object called 'testString' stored in the same Map which i can easily access and display using: $testString However how do i go about accessing the String array object (notSelected) from the Map inside the velocity template object? I have tried: $notSelected.get(0) $notSelected[0] $notSelected.[0] $

Velocity Unable To find Resources

做~自己de王妃 提交于 2019-12-24 00:56:14
问题 This question is already asked but i am trying the same thing that is in accepted answer protected static final String RESOURCE_LOADER = classpath.resource.loader.class"; static { System.out.println("Velocity Initialization Started"); velocityEngine = new VelocityEngine(); velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); velocityEngine.setProperty(RESOURCE_LOADER,ClasspathResourceLoader.class.getName()); try { velocityEngine.init(); } catch (Exception e) { LOG.error(

Not able to read Object values in Freemarker Template

大兔子大兔子 提交于 2019-12-24 00:36:16
问题 I am naot able to read the scala/java object values in Freemarker Templet I tried with this: case class ScheduleEmail(workOrderNo:String, name:String, woType:String, numberOfAssets:String, artisan:String, dueDate:Date,priority:String) object ScheduleMailSending extends App{ val scheduleEmail1= List(ScheduleEmail("1", "Oil Change1", "WO", "3", "XYZ", Date.valueOf("2015-01-01"), "High")) val configaration = new Configuration configaration.setClassForTemplateLoading(this.getClass, "/")

Velocity 2.0: NoClassDefFoundError: org/apache/velocity/runtime/log/CommonsLogLogChute

感情迁移 提交于 2019-12-23 20:23:52
问题 On starting up my Web app with Velocity 2.0 I'm getting the following error: Caused by: java.lang.NoClassDefFoundError: org/apache/velocity/runtime/log/CommonsLogLogChute at org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:240) at org.springframework.ui.velocity.VelocityEngineFactoryBean.afterPropertiesSet(VelocityEngineFactoryBean.java:60) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods