velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claude Brisson <cla...@renegat.net>
Subject Re: template and bean
Date Thu, 17 Jan 2008 06:34:58 GMT
You first have to put an instance of your bean in the Velocity context
with something like:

	context.put("jack",new Person());

and then use this instance in your templates:

	#set($jack.name = "Jack")
	Hello, $jack

Gaining access to the Velocity context depends upon your architecture
(standalone Java application, specific framework like Spring or Struts,
VelocityTools, ...).


  Claude

Le mercredi 16 janvier 2008 à 18:13 -0800, AngeloChen960 a écrit :
> Hi,
> 
> i have this template: hi $name
> and have a entity bean:
> public class Person {
>     private String name;
>    	public String getName() { return name; }
>     public void setName(String name) { this.name = name;}
> }
> 
> how to use an instance of Person? Thanks,
> 
> A.C.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message