velocity template

velocity template

View Answers

January 6, 2009 at 4:07 AM

Hi friend,

Velocity is an open source templating tool developed by an international volunteer community and hosted by the Apache Software Foundation's Jakarta Project.


Here is simple code:


import java.io.*;
import java.io.StringWriter;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;

public class HelloWorld {
public static void main( String[] args ) throws Exception {
VelocityEngine vengine = new VelocityEngine();
vengine.init();
// next, get the Template
Template temp = vengine.getTemplate("helloworld.vm");
//create a context and add data
VelocityContext context = new VelocityContext();
context.put("name", "World");
// now render the template into a StringWriter
StringWriter writer = new StringWriter();
temp.merge(context, writer);
System.out.println(writer.toString() );
}
}

-------------------------------------

Thanks.

Amardeep









Related Tutorials/Questions & Answers:
velocity template - Struts
velocity template  what is velocity template and how does it work? whats the flow of execution of velocity template? i want an example using velocity template?  Hi friend, Velocity is an open source templating tool
Version of com.bladejava>blade-template-velocity dependency
List of Version of com.bladejava>blade-template-velocity dependency
Advertisements
Maven Dependency blade-template-velocity >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of com.bladejava >> blade-template-velocity version0.0.1 in your project
Maven Dependency blade-template-velocity >> 0.0.2
You should include the dependency code given in this page to add Maven Dependency of com.bladejava >> blade-template-velocity version0.0.2 in your project
Maven Dependency blade-template-velocity >> 0.0.3
You should include the dependency code given in this page to add Maven Dependency of com.bladejava >> blade-template-velocity version0.0.3 in your project
Maven Dependency blade-template-velocity >> 0.0.4
You should include the dependency code given in this page to add Maven Dependency of com.bladejava >> blade-template-velocity version0.0.4 in your project
Maven Dependency blade-template-velocity >> 0.0.6
You should include the dependency code given in this page to add Maven Dependency of com.bladejava >> blade-template-velocity version0.0.6 in your project
XML handling in a template using Velocity
XML handling in a template using Velocity   ... in a velocity template and also shows that use of  macro to wrap HTML tag in velocity  template. The method used in this example 
Maven Repository/Dependency: com.bladejava | blade-template-velocity
Maven Repository/Dependency of Group ID com.bladejava and Artifact ID blade-template-velocity. Latest version of com.bladejava:blade-template-velocity dependencies. # Version Release Date
how to render my htmlstring from java class in velocity template?
how to render my htmlstring from java class in velocity template?  Hi, I have a java class generates html string dynamically based on the logic. I'm...! Ref: I read your article "Use Velocity to generate HTML document". -Chintu
Velocity
; Apache Velocity is template engine developed by apache foundation... of the web applications. In this tutorial you will learn Velocity template...? Velocity is a Java-based template engine. It permits web page designers
Maven dependency for com.bladejava - blade-template-velocity version 0.0.4 is released. Learn to use blade-template-velocity version 0.0.4 in Maven based Java projects
-template-velocity released The developers of   com.bladejava - blade-template-velocity project have released the latest version of this library on 06 Sep 2016, the released version of  com.bladejava - blade-template-velocity
Maven dependency for com.bladejava - blade-template-velocity version 0.0.3 is released. Learn to use blade-template-velocity version 0.0.3 in Maven based Java projects
-template-velocity released The developers of   com.bladejava - blade-template-velocity project have released the latest version of this library on 31 Aug 2016, the released version of  com.bladejava - blade-template-velocity
Maven dependency for com.bladejava - blade-template-velocity version 0.0.2 is released. Learn to use blade-template-velocity version 0.0.2 in Maven based Java projects
-template-velocity released The developers of   com.bladejava - blade-template-velocity project have released the latest version of this library on 09 Mar 2016, the released version of  com.bladejava - blade-template-velocity
Maven dependency for com.bladejava - blade-template-velocity version 0.0.8 is released. Learn to use blade-template-velocity version 0.0.8 in Maven based Java projects
-template-velocity released The developers of   com.bladejava - blade-template-velocity project have released the latest version of this library on 18 Sep 2017, the released version of  com.bladejava - blade-template-velocity
Maven dependency for com.bladejava - blade-template-velocity version 0.0.6 is released. Learn to use blade-template-velocity version 0.0.6 in Maven based Java projects
-template-velocity released The developers of   com.bladejava - blade-template-velocity project have released the latest version of this library on 20 Feb 2017, the released version of  com.bladejava - blade-template-velocity
Maven dependency for com.bladejava - blade-template-velocity version 0.0.5 is released. Learn to use blade-template-velocity version 0.0.5 in Maven based Java projects
-template-velocity released The developers of   com.bladejava - blade-template-velocity project have released the latest version of this library on 03 Jan 2017, the released version of  com.bladejava - blade-template-velocity
Maven dependency for com.bladejava - blade-template-velocity version 0.0.1 is released. Learn to use blade-template-velocity version 0.0.1 in Maven based Java projects
-template-velocity released The developers of   com.bladejava - blade-template-velocity project have released the latest version of this library on 16 Feb 2016, the released version of  com.bladejava - blade-template-velocity
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for blade-template-velocity version 0.0.8
-template-velocity version 0.0.8. You can add these depency in your project to get com.bladejava:blade-template-velocity:0.0.8 Java library in your project.. Maven...-template-velocity version 0.0.8 In this section have given the dependency code
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for blade-template-velocity version 0.0.6
-template-velocity version 0.0.6. You can add these depency in your project to get com.bladejava:blade-template-velocity:0.0.6 Java library in your project.. Maven...-template-velocity version 0.0.6 In this section have given the dependency code
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for blade-template-velocity version 0.0.5
-template-velocity version 0.0.5. You can add these depency in your project to get com.bladejava:blade-template-velocity:0.0.5 Java library in your project.. Maven...-template-velocity version 0.0.5 In this section have given the dependency code
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for blade-template-velocity version 0.0.4
-template-velocity version 0.0.4. You can add these depency in your project to get com.bladejava:blade-template-velocity:0.0.4 Java library in your project.. Maven...-template-velocity version 0.0.4 In this section have given the dependency code
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for blade-template-velocity version 0.0.3
-template-velocity version 0.0.3. You can add these depency in your project to get com.bladejava:blade-template-velocity:0.0.3 Java library in your project.. Maven...-template-velocity version 0.0.3 In this section have given the dependency code
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for blade-template-velocity version 0.0.2
-template-velocity version 0.0.2. You can add these depency in your project to get com.bladejava:blade-template-velocity:0.0.2 Java library in your project.. Maven...-template-velocity version 0.0.2 In this section have given the dependency code
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for blade-template-velocity version 0.0.1
-template-velocity version 0.0.1. You can add these depency in your project to get com.bladejava:blade-template-velocity:0.0.1 Java library in your project.. Maven...-template-velocity version 0.0.1 In this section have given the dependency code
Define and use Macro in Velocity
Define and use Macro in Velocity   ... in velocity  template and also shows how to use Iterator in velocity  template...:- Initialize velocity run time engine through method  init(). 2:- Create object
Velocity Macro with Parameters
Velocity Macro with Parameters   ... with parameters in velocity  template. Example given below show you, how to display date and time velocity. The method used in this example 
XML and Velocity
XML and Velocity  How to create xml file using velocity template engine
Velocity Iterator Tool Example
Velocity Iterator Tool Example     ...; template. The method used in this example are described below:-  1:- Initialize velocity run time engine through method  init(). 2:- Create object
How to use foreach loop in velocity
How to use foreach loop in velocity   ... in velocity  template. The method used in this example are described below:-  1:- Initialize velocity run time engine through method  init(). 2:- Create
What is Velocity?
; Velocity is a Java-based template engine. It permits... in the context Velocity Template Language (VTL): The Velocity Template Language (VTL) provides the easiest and simplest way
Version of velocity>velocity dependency
List of Version of velocity>velocity dependency
Show content of .vm file as output using Velocity
Show content of .vm file as output using Velocity  ... content of .vm file using velocity and also shows how to use Iterator in velocity  template. The method used in this example are described below:- 
Use macro to wrap HTML tags in velocity
Use macro to wrap HTML tags in velocity   ... in velocity  template. The method used in this example are described below:-  1:- Initialize velocity run time engine through method  init
Version of velocity>velocity-dep dependency
List of Version of velocity>velocity-dep dependency
apache velocity maven dependency
apache velocity maven dependency  Hi, What is the apache velocity maven dependency? I am learning velocity template and searching for the dependency to be added to maven pom.xml file. Thanks   Hi, Here is the code
Artifacts of velocity
List of Artifacts of velocity maven depenency
Version of plexus-velocity>plexus-velocity dependency
List of Version of plexus-velocity>plexus-velocity dependency
Version of velocity-dvsl>velocity-dvsl dependency
List of Version of velocity-dvsl>velocity-dvsl dependency
Version of velocity-tools>velocity-tools dependency
List of Version of velocity-tools>velocity-tools dependency
Use if in velocity
Use if in velocity       This example shows you how to use if statement in velocity. Description of methods used in the example given below.... 1:- Initialize velocity run time
Version of velocity-tools>velocity-tools-view dependency
List of Version of velocity-tools>velocity-tools-view dependency
Version of velocity-tools>velocity-tools-generic dependency
List of Version of velocity-tools>velocity-tools-generic dependency
Maven Repository/Dependency: velocity | velocity
Maven Repository/Dependency of Group ID velocity and Artifact ID velocity. Latest version of velocity:velocity dependencies. # Version Release Date 1 1.3.1 02 Jan 2016
Hibernate Template
Hibernate Template  Define Hibernate Template
Velocity with External Properties
for controlling template methods and properties. "runtime.log = velocity_example.log... Velocity with External Properties       This Example shows you how to use Velocity
Use if and elseif statements in velocity
Use if and elseif statements in velocity   ... in velocity. The method used in this example are described below:-  1:- Initialize velocity run time engine through method  init(). 2
ModuleNotFoundError: No module named 'velocity'
ModuleNotFoundError: No module named 'velocity'  Hi, My Python... 'velocity' How to remove the ModuleNotFoundError: No module named 'velocity... to install padas library. You can install velocity python with following
How to define variable in Velocity
How to define variable in Velocity   ... in velocity. Methods used in this example are described below:- 1:- Initialize velocity run time engine through method  init(). 2:- Create object
Version of maven>velocity dependency
List of Version of maven>velocity dependency

Ads