1 24 package org.riotfamily.website.generic.view; 25 26 import java.util.Iterator ; 27 import java.util.Map ; 28 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 32 import org.riotfamily.common.markup.DocumentWriter; 33 import org.riotfamily.common.markup.Html; 34 import org.riotfamily.common.web.util.ServletUtils; 35 import org.springframework.core.style.StylerUtils; 36 import org.springframework.web.servlet.View; 37 38 45 public class DumpModelView implements View { 46 47 public static final String DEFAULT_STYLE_SHEET = 48 "http://www.riotfamily.org/downloads/dump-model.css"; 49 50 private String styleSheet = DEFAULT_STYLE_SHEET; 51 52 59 public void setStyleSheet(String styleSheet) { 60 this.styleSheet = styleSheet; 61 } 62 63 public String getContentType() { 64 return "text/html"; 65 } 66 67 public void render(Map model, HttpServletRequest request, 68 HttpServletResponse response) throws Exception { 69 70 DocumentWriter out = new DocumentWriter(response.getWriter()); 71 out.start(Html.HTML); 72 73 out.start(Html.HEAD); 74 out.start(Html.TITLE).body("Model Dump").end(); 75 if (styleSheet != null) { 76 out.start(Html.LINK).attribute(Html.LINK_REL, "stylesheet") 77 .attribute(Html.LINK_HREF, 78 ServletUtils.resolveUrl(styleSheet, request)).end(); 79 } 80 out.end(); 81 82 out.start(Html.BODY).start(Html.DL); 83 Iterator it = model.entrySet().iterator(); 84 while (it.hasNext()) { 85 Map.Entry entry = (Map.Entry ) it.next(); 86 out.start(Html.DT).body(entry.getKey().toString()).end(); 87 out.start(Html.DD).body(StylerUtils.style(entry.getValue())).end(); 88 } 89 out.closeAll(); 90 } 91 } 92 | Popular Tags |