06-04-2008 08:39 PM
public class SampleWebScript extends AbstractWebScript
{
public void execute(WebScriptRequest req, WebScriptResponse res)
throws IOException
{
try
{
Container c = getContainer();
Writer writer = res.getWriter();
String bar = "Hello World";
Object model = new SampleModel(bar);
String templatePath = "org/alfresco/demo/foo.ftl";
if(c.getTemplateProcessor().hasTemplate(templatePath))
{
c.getTemplateProcessor().process(templatePath,model,writer);
}
}
catch (Exception e)
{
throw new WebScriptException(e.getMessage());
}
}
private class SampleModel
{
private String message;
private SampleModel(String s)
{
this.message = s;
}
public String getMessage()
{
return message;
}
public void setMessage(String message)
{
this.message = message;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<workflow-definitions>
<message>${message}</message>
</workflow-definitions>
c.getTemplateProcessor().process(templatePath,model,writer);
Error during processing of the template 'Expression message is undefined on line 4, column 20 in org/alfresco/demo/foo.ftl.'. Please contact your system administrator.
06-05-2008 05:21 PM
String templatePath = "org/alfresco/demo/foo.ftl";
Map<String, Object> model = new HashMap<String, Object>();
model.put("message", "Hello World");
Writer writer = res.getWriter();
public class SampleWebScript extends AbstractWebScript {
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
String templatePath = "org/alfresco/demo/foo.ftl";
Map<String, Object> model = new HashMap<String, Object>();
model.put("message", "Hello World");
Writer writer = res.getWriter();
renderTemplate(templatePath,model,writer);
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.