Hi,
I would like to use a JavaBean in a template (like the example code
below)
But it seems that this is not possible (in other common templates
libraries like velocity or freemarker this is no problem)
Could anybody of you give me a hint wheter this could be done with
this template engine (and how)?
TIA
Martin
example code:
SOY Template:
{namespace com.test.template}
/**
*
* @param user The user
*/
{template .UserProfile}
This is user {$
user.name}!
{/template}
// USAGE:
...
UserBean bean=new UserBean("myname");
Map<String, Object> mapData=new HashMap<String, Object>();
mapData.put("user",bean);
String result=getSoyTofu().render
("com.test.template.UserProfile",mapData,null);
writer.write(result);
....
// BEAN def
public class UserBean {
private String name;
public UserBean(String name) {
this.name=name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}