Search in sources :

Example 1 with AbstractView

use of org.springframework.web.servlet.view.AbstractView in project gocd by gocd.

the class FileModelAndView method createFileView.

public static ModelAndView createFileView(File file, String sha) throws Exception {
    boolean hasChanged = isFileChanged(file, sha);
    if (!hasChanged) {
        return new ModelAndView(new AbstractView() {

            protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception {
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                response.getWriter().close();
            }
        });
    } else {
        HashMap model = new HashMap();
        if (file instanceof ZippedArtifact) {
            model.put(FileView.NEED_TO_ZIP, true);
        }
        model.put("targetFile", file);
        return new ModelAndView("fileView", model);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AbstractView(org.springframework.web.servlet.view.AbstractView) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) HttpServletResponse(javax.servlet.http.HttpServletResponse) HashMap(java.util.HashMap) Map(java.util.Map) IOException(java.io.IOException) ZippedArtifact(com.thoughtworks.go.server.domain.ZippedArtifact)

Example 2 with AbstractView

use of org.springframework.web.servlet.view.AbstractView in project engine by craftercms.

the class CrafterPageView method renderActualView.

protected void renderActualView(String pageViewName, Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
    View actualView = delegatedViewResolver.resolveViewName(pageViewName, locale);
    if (actualView == null) {
        throw new RenderingException("No view was resolved for page view name '" + pageViewName + "'");
    }
    if (actualView instanceof AbstractView) {
        ((AbstractView) actualView).setContentType(getContentType());
    }
    actualView.render(model, request, response);
}
Also used : AbstractView(org.springframework.web.servlet.view.AbstractView) RenderingException(org.craftercms.engine.exception.RenderingException) AbstractView(org.springframework.web.servlet.view.AbstractView) View(org.springframework.web.servlet.View)

Aggregations

AbstractView (org.springframework.web.servlet.view.AbstractView)2 ZippedArtifact (com.thoughtworks.go.server.domain.ZippedArtifact)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 RenderingException (org.craftercms.engine.exception.RenderingException)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 View (org.springframework.web.servlet.View)1