use of org.beetl.ext.web.WebRender in project beetl2.0 by javamonkey.
the class ServletGroupTemplate method render.
public void render(String child, HttpServletRequest request, HttpServletResponse response) {
WebRender render = new WebRender(groupTemplate);
render.render(child, request, response);
}
use of org.beetl.ext.web.WebRender in project beetl2.0 by javamonkey.
the class BeetlSpringView method renderMergedTemplateModel.
/* ----- ----- ----- ----- 实现方法 ----- ----- ----- ----- */
/**
* 渲染指定视图
*
* @param model
* @param request
* @param response
* @throws NoSuchBeanDefinitionException
* 如果未设置GroupTemplate,且Spring上下文中也没有唯一的GroupTemplate bean
* @throws NoUniqueBeanDefinitionException
* 如果未设置GroupTemplate,且Spring上下文中有多个GroupTemplate bean
*/
@Override
protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws NoSuchBeanDefinitionException, NoUniqueBeanDefinitionException {
// 如果未指定groupTemplate,取上下文中唯一的GroupTemplate对象
if (groupTemplate == null) {
groupTemplate = getApplicationContext().getBean(GroupTemplate.class);
}
// 渲染方法
WebRender render = new WebRender(groupTemplate) {
@Override
protected void modifyTemplate(Template template, String key, HttpServletRequest request, HttpServletResponse response, Object... args) {
Map<?, ?> model = (Map<?, ?>) args[0];
for (Entry<?, ?> entry : model.entrySet()) {
String name = (String) entry.getKey();
Object value = entry.getValue();
template.binding(name, value);
}
}
};
String path = getUrl();
render.render(path, request, response, model);
}
use of org.beetl.ext.web.WebRender 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);
}
use of org.beetl.ext.web.WebRender in project beetl2.0 by javamonkey.
the class BeetlActionResult method render.
@Override
public void render(ActionRequest actionRequest, Object resultValue) throws Exception {
// TODO Auto-generated method stub
WebRender render = new WebRender(groupTemplate);
render.render((String) resultValue, actionRequest.getHttpServletRequest(), actionRequest.getHttpServletResponse());
}
Aggregations