use of org.beetl.core.GroupTemplate in project beetl2.0 by javamonkey.
the class Struts2BeetlActionResult method doExecute.
protected void doExecute(String locationArg, ActionInvocation invocation) throws Exception {
ActionContext ctx = invocation.getInvocationContext();
HttpServletRequest req = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse rsp = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE);
if (!locationArg.startsWith("/")) {
String base = ResourceUtil.getResourceBase(req);
locationArg = base + "/" + locationArg;
}
Object action = invocation.getAction();
Map<String, Object> values = reflectionProvider.getBeanMap(action);
rsp.setContentType(this.pContentType);
WebRender render = new WebRender(groupTemplate) {
protected void modifyTemplate(Template template, String key, HttpServletRequest request, HttpServletResponse response, Object... args) {
Map model = (Map) args[0];
for (Object o : model.entrySet()) {
Entry entry = (Entry) o;
String name = (String) entry.getKey();
Object value = entry.getValue();
template.binding(name, value);
}
}
};
render.render(locationArg, req, rsp, values);
}
Aggregations