velocity template 1 Answer(s) 4 years and 5 months ago
Posted in : Struts
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.
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 Pages:
velocity template - Struts velocity template what is velocitytemplate and how does it work? whats the flow of execution of velocitytemplate? i want an example using velocitytemplate? Hi friend,
Velocity is an open source templating tool
Velocity
method in velocitytemplate.
Calculation Example...
This
Example shows you how
to use class properties in your velocitytemplate.
XML handling in a template using Velocity
XML handling in a template using Velocity
XML handling in a template using Velocity
 ... in a velocitytemplate and
also shows that use of macro to wrap HTML tag in
velocity
template. The method
used in this example 
XML and Velocity
XML and Velocity How to create xml file using velocitytemplate engine
how to render my htmlstring from java class in velocity template?
how to render my htmlstring from java class in velocitytemplate? 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
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
 ... in velocity
template.
Example given below show you, how
to display date and time velocity. The method used in this example are
described below
What is Velocity?
What is Velocity?
Velocity is a Java-based template engine. It permits...
VelocityTemplate Language (VTL):
The Velocity
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
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
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
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
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:- 
How to use List in velocity
How to use List in velocity
This
Example shows you how
to use List in velocity. ... velocity run
time
engine through method init().
2:- Create object
How to use Map in velocity
How to use Map in velocity
This
Example shows you how
to use map in velocity. The method... velocity run
time
engine through method init().
2:- Create object
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
Include template file in another template file
Include template file in another template file
 ... template file. The method used in this example are
described below:-
1:- Initialize velocity run
time
engine through method init().
2
Use if else and end statements in velocity
Use if else and end statements in velocity
 ... if in velocity. The method used in this example
are described below:-
1:- Initialize velocity run time
engine through method init().
2:- Create object
How to use dollar sign in velocity
How to use dollar sign in velocity
 ... in velocity.
The method used in this example
are described below:-
1:- Initialize velocity run
time engine through method init().
2:- Create object
Foreach loop with negative index in velocity
Foreach loop with negative index
in velocity
 ... with negative index in velocity.
The method used in this example
are described below:-
1:- Initialize velocity run
time engine through method 
Use Velocity to generate HTML document
Use Velocity to generate HTML document
 ... document using velocity. The method used in this example are
described below:-
1:- Initialize velocity run
time
engine through method init().
2
How to set a variable value using velocity
How to set a variable value using velocity
 ... using velocity.
The method used in this
example are
described below:-
1:- Initialize velocity run
time
engine through method init().
2:- Create
Show output as a xml file using Velocity
Show output as a xml file using Velocity
 ... in velocity. The method
used in this example are
described below:-
1:- Initialize velocity run
time
engine through method init().
2
Call class methods
;
This Example shows you
how
to call class method in velocitytemplate.
Steps used in the code given below :
1: Initialize velocity... this (Date) object in velocitytemplate.
CallClassMethods.java
Reference Class Properties
in your velocitytemplate.
Steps used in the code given below :
1: Initialize velocity run time engine through method init().
2: Create object...;
Velocity.getTemplate("./src/velocity/ClassReference/ClassProperties.vm");
 
Simteec
. It it based upon the velocitytemplate engine. Code is generated by specifying a template- and a
properties-file, which is needed to define the variables for the template.
Contact here for more detail: http://simteec.sourceforge.net
Html Template - JSP-Servlet
Html Template I use a template to design my website,but some problems arised using template.I pass flag update and insert as a hidden field on to the servlet,the response of the servlet is a jsp page.on this page template
Velocity Web Edit Velocity Web Edit
Velocity Web Edit is a Velocity and HTML aware editor... Assist
Velocity Variables Names
Velocity Variable Methods
Template - Java Beginners
Template Develop a template for linked-list class along with its methods in Java
Integration of velocity with struts 2.0 - Struts
Integration of velocity with struts 2.0 Hi ,
I am going to implement Struts 2 with Velocity. Is there any plugin available? I am totally new to velocity.
Please tell the steps to integrate Struts 2 and velocity
Replacing a template with actual values
Replacing a template with actual values I have a template
Hello $$personename$$,
You are eligible for this $$planname$$ from today onwards. CONDITIONAL_TEXT_1
Regards,$$managerName$$
I wanna repalce this place
How to pass java.util.Properties in properties
java.util.Properties to in velocity. The methods
used in this example are
described below:-
1:- Initialize velocity run
time
engine through method init().
2:- Create object of
VelocityContext Class.
3:- Create Template
Smarty Templates PHP, Smarty Template Tutorials
Learn Smarty Templates Engine for PHP
Smarty is template engine for PHP, it enables the php programmers to develop web applications using the smarty templates. Learn how to create Smarty Template now.
 
useitgenerator
useitgenerator
UseitGenerator is a lightweight generator for eclipse
uml2 models. It is base on the velocitytemplate engine. It has a simple
generation process. You
Data Type: number
;
This Example shows you how
to use number data type in velocity. Methods used in this
example are
described below:-
1:- Initialize velocity run... of
VelocityContext Class.
3:- Create Template
class object, Template
class object is used
POI Word document (Letter Template)
POI Word document (Letter Template) Dear Team,
i need code for generating word document(letter format).
i am unable to get the code for
formats, font settings, letter type
settings.
please help me for the same.
Thanks
Data Type: bool
;
This Example shows you how
to use bool datatype in velocity. Methods used in this
example are
described below:-
1:- Initialize velocity run
time...;Class.
3:- Create Template
class object, Template class object is used
Date Tool Example
;
This Example shows you how
to display date and time velocity. ... velocity run
time
engine through method init().
2:- Create object of
VelocityContext Class.
3:- Create Template
class object, Template
 
How to find the exact PHP template I need?
How to find the exact PHP template I need? Hi!
I'm a PHP Pro?I think I am one?, but this is the first time for me to try a PHP template, so I have... the/a right PHP template?
Needs for a PHP Template:
- it is efficient since the PHP
Data Type: String
;
This Example shows you how
to use string data type in velocity. ... velocity run
time
engine through method init().
2:- Create object of
VelocityContext Class.
3:- Create Template
class object, Template
class object
Open Source web Templates
in Java
Velocity is a Java-based template engine. It permits web page designers... template is a pre-made website with essentially no content. This makes it easy... need to customize your template is photo editing software like Photoshop, and any