Java Code Examples for javax.mvc.engine.ViewEngineContext#getRequest()

The following examples show how to use javax.mvc.engine.ViewEngineContext#getRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThymeleafViewEngine.java    From krazo with Apache License 2.0 6 votes vote down vote up
@Override
public void processView(ViewEngineContext context) throws ViewEngineException {
    try {
        HttpServletRequest request = context.getRequest(HttpServletRequest.class);
        HttpServletResponse response = context.getResponse(HttpServletResponse.class);

        CDIWebContext ctx = new CDIWebContext(beanManager, request, response, servletContext, context.getLocale());

        Map<String, Object> model = new HashMap<>(context.getModels().asMap());
        model.put("request", request);
        ctx.setVariables(model);

        try {
            engine.process(resolveView(context), ctx, response.getWriter());
            response.flushBuffer();
        } finally {
            ctx.close();
        }
    } catch (IOException e) {
        throw new ViewEngineException(e);
    }
}
 
Example 2
Source File: ThymeleafViewEngine.java    From ozark with Apache License 2.0 6 votes vote down vote up
@Override
public void processView(ViewEngineContext context) throws ViewEngineException {
    try {
        HttpServletRequest request = context.getRequest(HttpServletRequest.class);
        HttpServletResponse response = context.getResponse(HttpServletResponse.class);

        CDIWebContext ctx = new CDIWebContext(beanManager, request, response, servletContext, context.getLocale());

        Map<String, Object> model = new HashMap<>(context.getModels().asMap());
        model.put("request", request);
        ctx.setVariables(model);

        try {
            engine.process(resolveView(context), ctx, response.getWriter());
            response.flushBuffer();
        } finally {
            ctx.close();
        }
    } catch (IOException e) {
        throw new ViewEngineException(e);
    }
}
 
Example 3
Source File: JtwigViewEngine.java    From krazo with Apache License 2.0 4 votes vote down vote up
public void processView(ViewEngineContext context) throws ViewEngineException {

        try {

            Map<String, Object> model = new HashMap<>(context.getModels().asMap());
            model.put("request", context.getRequest(HttpServletRequest.class));

            HttpServletRequest request = context.getRequest(HttpServletRequest.class);
            HttpServletResponse response = context.getResponse(HttpServletResponse.class);

            jtwigRenderer.dispatcherFor(resolveView(context)).with(model).render(request,response);

        } catch (ServletException | IOException e) {
            throw new ViewEngineException(e);
		}
    }
 
Example 4
Source File: JtwigViewEngine.java    From ozark with Apache License 2.0 4 votes vote down vote up
public void processView(ViewEngineContext context) throws ViewEngineException {

        try {

            Map<String, Object> model = new HashMap<>(context.getModels().asMap());
            model.put("request", context.getRequest(HttpServletRequest.class));

            HttpServletRequest request = context.getRequest(HttpServletRequest.class);
            HttpServletResponse response = context.getResponse(HttpServletResponse.class);

            jtwigRenderer.dispatcherFor(resolveView(context)).with(model).render(request,response);

        } catch (ServletException | IOException e) {
            throw new ViewEngineException(e);
		}
    }