Search in sources :

Example 1 with HTMLPage

use of com.opensymphony.module.sitemesh.HTMLPage in project grails-core by grails.

the class SpringMVCViewDecorator method render.

public void render(Content content, Map<String, ?> model, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) {
    HTMLPage htmlPage = GSPSitemeshPage.content2htmlPage(content);
    request.setAttribute(RequestConstants.PAGE, htmlPage);
    // get the dispatcher for the decorator
    if (!response.isCommitted()) {
        boolean dispatched = false;
        try {
            request.setAttribute(GrailsLayoutView.GSP_SITEMESH_PAGE, new GSPSitemeshPage(true));
            try {
                view.render(model, request, response);
                dispatched = true;
                if (!response.isCommitted()) {
                    response.getWriter().flush();
                }
            } catch (Exception e) {
                cleanRequestAttributes(request);
                String message = "Error applying layout : " + getName();
                if (view instanceof AbstractGrailsView) {
                    ((AbstractGrailsView) view).rethrowRenderException(e, message);
                } else {
                    throw new RuntimeException(message, e);
                }
            }
        } finally {
            if (!dispatched) {
                cleanRequestAttributes(request);
            }
        }
    }
    request.removeAttribute(RequestConstants.PAGE);
    request.removeAttribute(GrailsLayoutView.GSP_SITEMESH_PAGE);
}
Also used : HTMLPage(com.opensymphony.module.sitemesh.HTMLPage) AbstractGrailsView(org.grails.web.servlet.view.AbstractGrailsView)

Aggregations

HTMLPage (com.opensymphony.module.sitemesh.HTMLPage)1 AbstractGrailsView (org.grails.web.servlet.view.AbstractGrailsView)1