1 package fr.improve.struts.taglib.layout.util; 2 3 import java.util.MissingResourceException ; 4 5 import javax.servlet.jsp.JspException ; 6 import javax.servlet.jsp.PageContext ; 7 import javax.servlet.jsp.tagext.Tag ; 8 import javax.servlet.jsp.tagext.TagSupport ; 9 10 import fr.improve.struts.taglib.layout.HtmlTag; 11 import fr.improve.struts.taglib.layout.PanelTag; 12 import fr.improve.struts.taglib.layout.skin.Skin; 13 18 public class ImagePanel implements PanelInterface { 19 private String styleClass; 20 private boolean isNested = false; 21 22 private String bg_width; 23 private String bg_height; 24 private String bg_bottom_height; 25 private String bg_top_height; 26 private String bottom; 27 private String bottom_LEFT; 28 private String bottom_RIGHT; 29 private String left; 30 private String right; 31 private String top; 32 private String top_LEFT; 33 private String top_RIGHT; 34 35 private String imageDir; 36 public void doAfterBody(StringBuffer buffer) { 37 buffer.append("</table></td>\n"); 38 } 39 public void doBeforeBody(StringBuffer buffer, String align) { 40 buffer.append("<td class="); 41 buffer.append(styleClass); 42 buffer.append("><table width=\"100%\""); 43 if (align!=null) { 44 buffer.append(" align=\""); 45 buffer.append(align); 46 buffer.append("\""); 47 } 48 buffer.append(" border=0>\n"); 49 } 50 53 public void doEndPanel(StringBuffer buffer) { 54 56 buffer.append("<td width=\""); 58 buffer.append(bg_width); 59 buffer.append("\" background=\""); 60 buffer.append(right); 61 buffer.append("\" style=\"background-repeat:repeat-y;\">" + doPrintClearPix() + "</td>"); 62 buffer.append("</tr>"); 63 64 buffer.append("<tr>"); 66 67 buffer.append("<td width=\""); 68 buffer.append(bg_width); 69 buffer.append("\" height=\""); 70 buffer.append(bg_bottom_height); 71 buffer.append("\"><img SRC=\""); 72 buffer.append(bottom_LEFT); 73 buffer.append("\"></td>"); 74 75 buffer.append("<td height=\""); 76 buffer.append(bg_bottom_height); 77 buffer.append("\" background=\""); 78 buffer.append(bottom); 79 buffer.append("\" style=\"background-repeat:repeat-x;\">"+ doPrintClearPix() + "</td>"); 80 81 buffer.append("<td width=\""); 82 buffer.append(bg_width); 83 buffer.append("\" height=\""); 84 buffer.append(bg_bottom_height); 85 buffer.append("\"><img SRC=\""); 86 buffer.append(bottom_RIGHT); 87 buffer.append("\" valign=\"top\"></td>"); 88 89 buffer.append("</tr>"); 90 91 buffer.append("</table>"); 93 } 94 95 public String doPrintClearPix(){ 96 return "<img SRC=\""+imageDir+ "/clearpix.gif\" height=\"1\" width=\"1\" border=\"0\">"; 97 } 98 99 public void doPrintBlankLine(StringBuffer buffer, int cols) { 100 buffer.append("<tr><td colspan=" + cols + ">" + doPrintClearPix() + "</td></tr>\n"); 101 } 102 105 public void doPrintTitle(StringBuffer buffer, String title) { 106 buffer.append("<td"); 107 108 if (title!=null) { 109 buffer.append("><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\""); 110 buffer.append(styleClass); 111 buffer.append("\"><tr><th class=\""); 112 buffer.append(styleClass); 113 buffer.append("\" height=\""); 114 buffer.append(bg_top_height); 115 buffer.append("\" background=\""); 116 buffer.append(top); 117 buffer.append("\" style=\"background-repeat:repeat-x;\""); 118 buffer.append("\">"); 119 buffer.append(title); 120 buffer.append("</th></tr></table>"); 121 } else { 122 buffer.append(" height=\""); 123 buffer.append(bg_top_height); 124 buffer.append("\" background=\""); 125 buffer.append(top); 126 buffer.append("\" style=\"background-repeat:repeat-x;\">" + doPrintClearPix()); 127 } 128 buffer.append("</td>"); 129 130 buffer.append("<td width=\""); 131 buffer.append(bg_width); 132 buffer.append("\" height=\""); 133 buffer.append(bg_top_height); 134 buffer.append("\"><img SRC=\""); 135 buffer.append(top_RIGHT); 136 buffer.append("\"></td>"); 137 138 buffer.append("</tr>"); 139 140 buffer.append("<tr>"); 142 143 buffer.append("<td width=\""); 144 buffer.append(bg_width); 145 buffer.append("\" background=\""); 146 buffer.append(left); 147 buffer.append("\" style=\"background-repeat:repeat-y;\">" + doPrintClearPix() + "</td>"); 148 149 } 151 154 public void doStartPanel(StringBuffer buffer, String align, String width) { 155 buffer.append("<table cellspacing=0 cellpadding=0 border=0"); 157 if (align!=null) { 158 buffer.append(" align="); 159 buffer.append(align); 160 } 161 if (width!=null) { 162 buffer.append(" width="); 163 buffer.append(width); 164 } 165 buffer.append(">"); 166 167 buffer.append("<tr>"); 169 170 buffer.append("<td width=\""); 171 buffer.append(bg_width); 172 buffer.append("\" height=\""); 173 buffer.append(bg_top_height); 174 buffer.append("\"><img SRC=\""); 175 buffer.append(top_LEFT); 176 buffer.append("\"></td>"); 177 } 178 public void init(PageContext pageContext, String in_styleClass, TagSupport in_panel) throws JspException { 179 this.styleClass = in_styleClass; 180 181 Skin l_skin = LayoutUtils.getSkin(pageContext.getSession()); 182 imageDir = l_skin.getImageDirectory(pageContext.getRequest()); 183 184 try { 185 bg_width = l_skin.getProperty("width"); 186 bg_height = l_skin.getProperty("height"); 187 188 top_LEFT = l_skin.getProperty("top_LEFT"); 189 top = l_skin.getProperty("top"); 190 top_RIGHT = l_skin.getProperty("top_RIGHT"); 191 left = l_skin.getProperty("left"); 192 right = l_skin.getProperty("right"); 193 bottom_LEFT = l_skin.getProperty("bottom_LEFT"); 194 bottom = l_skin.getProperty("bottom"); 195 bottom_RIGHT = l_skin.getProperty("bottom_RIGHT"); 196 } catch (MissingResourceException e) { 197 throw new JspException ("Bad imagepanel configuration: can't find key " + e.getKey() + " in file " + e.getClassName()); 198 } 199 200 try { 201 bg_top_height = l_skin.getProperty("top_height"); 202 bg_bottom_height = l_skin.getProperty("bottom_height"); 203 204 } catch (MissingResourceException e) { 205 if (bg_height.length()!=0){ 206 bg_bottom_height = bg_height; 207 bg_top_height = bg_height; 208 } 209 } 210 211 Tag lc_parent = in_panel!=null ? TagSupport.findAncestorWithClass(in_panel, PanelTag.class) : null; 212 isNested = !LayoutUtils.isPanelNesting() && lc_parent != null && !(lc_parent instanceof HtmlTag); 213 } 214 } 215 | Popular Tags |