1 package fr.improve.struts.taglib.layout; 2 3 import java.util.ResourceBundle ; 4 5 import javax.servlet.jsp.JspException ; 6 7 import fr.improve.struts.taglib.layout.util.LayoutUtils; 8 import fr.improve.struts.taglib.layout.util.TagUtils; 9 10 24 public class PanelTag2 extends LabelledTag { 25 protected int cols = 2; 26 protected String width; 27 protected String align = "center"; 28 public final static String CENTER = "center"; 29 public final static String LEFT = "left"; 30 public final static String RIGHT = "rigth"; 31 32 private ResourceBundle resBundle; 33 36 protected void doAfterBody(StringBuffer buffer) { 37 buffer.append("</table></td></tr>\n"); 38 } 39 42 protected void doBeforeBody(StringBuffer buffer) { 43 doBeforeBody(buffer, align); 44 } 45 49 protected void doBeforeBody(StringBuffer buffer, String align) { 50 buffer.append("<tr><td class="); 51 buffer.append(styleClass); 52 buffer.append("><table align=" + align +" border=0>\n"); 53 } 54 57 protected void doEndPanel(StringBuffer buffer) throws JspException { 58 buffer.append("</table></td>\n"); 59 60 String bg_width = resBundle.getString("width"); 61 String bg_height = resBundle.getString("height"); 62 63 64 buffer.append("<td width=\""); 66 buffer.append(bg_width); 67 buffer.append("\" background=\""); 68 buffer.append(resBundle.getString("right")); 69 buffer.append("\" style=\"background-repeat:repeat-y;\"> </td>"); 70 buffer.append("</tr>"); 71 72 buffer.append("<tr>"); 74 75 buffer.append("<td width=\""); 76 buffer.append(bg_width); 77 buffer.append("\" height=\""); 78 buffer.append(bg_height); 79 buffer.append("\"><img SRC=\""); 80 buffer.append(resBundle.getString("bottom_LEFT")); 81 buffer.append("\"></td>"); 82 83 buffer.append("<td height=\""); 84 buffer.append(bg_height); 85 buffer.append("\" background=\""); 86 buffer.append(resBundle.getString("bottom")); 87 buffer.append("\" style=\"background-repeat:repeat-x;\"> </td>"); 88 89 buffer.append("<td width=\""); 90 buffer.append(bg_width); 91 buffer.append("\" height=\""); 92 buffer.append(bg_height); 93 buffer.append("\"><img SRC=\""); 94 buffer.append(resBundle.getString("bottom_RIGHT")); 95 buffer.append("\"></td>"); 96 97 buffer.append("</tr>"); 98 99 buffer.append("</table>"); 101 } 102 public int doEndLayoutTag() throws JspException { 103 StringBuffer buffer = new StringBuffer (); 104 doAfterBody(buffer); 105 doEndPanel(buffer); 106 TagUtils.write(pageContext, buffer.toString()); 107 return EVAL_PAGE; 108 } 109 112 protected void doPrintBlankLine(StringBuffer buffer) { 113 buffer.append("<tr><td colspan=" + cols + "> </td></tr>\n"); 114 } 115 120 protected void doPrintTitle(StringBuffer buffer) throws JspException { 121 } 132 135 protected void doStartPanel(StringBuffer buffer) throws JspException { 136 doStartPanel(buffer, align); 137 } 138 142 protected void doStartPanel(StringBuffer buffer, String align) throws JspException { 143 144 String l_skin = LayoutUtils.getSkin(pageContext.getSession()).getCssFileName(); 145 if (l_skin.endsWith(".css")) l_skin = l_skin.substring(0,l_skin.length()-4); 146 resBundle = ResourceBundle.getBundle("com.applicationservers.forum.client.struts.Layout",new java.util.Locale (l_skin,(styleClass==null?"":styleClass))); 147 148 buffer.append("<table cellspacing=0 cellpadding=0 border=0 align="); 150 buffer.append(align); 151 if (width!=null) { 152 buffer.append(" width="); 153 buffer.append(width); 154 } 155 buffer.append(">"); 156 157 String bg_width = resBundle.getString("width"); 158 String bg_height = resBundle.getString("height"); 159 160 buffer.append("<tr>"); 162 163 buffer.append("<td width=\""); 164 buffer.append(bg_width); 165 buffer.append("\" height=\""); 166 buffer.append(bg_height); 167 buffer.append("\"><img SRC=\""); 168 buffer.append(resBundle.getString("top_LEFT")); 169 buffer.append("\"></td>"); 170 171 buffer.append("<td"); 172 173 String label = getLabel(); 174 if (label!=null) { 175 buffer.append("><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\""); 176 buffer.append(styleClass); 177 buffer.append("\"><tr><th class=\""); 178 buffer.append(styleClass); 179 buffer.append("\">"); 180 buffer.append(getLabel()); 181 buffer.append("</th></tr></table>"); 182 } else { 183 buffer.append(" height=\""); 184 buffer.append(bg_height); 185 buffer.append("\" background=\""); 186 buffer.append(resBundle.getString("haut")); 187 buffer.append("\" style=\"background-repeat:repeat-x;\"> "); 188 } 189 buffer.append("</td>"); 190 191 buffer.append("<td width=\""); 192 buffer.append(bg_width); 193 buffer.append("\" height=\""); 194 buffer.append(bg_height); 195 buffer.append("\"><img SRC=\""); 196 buffer.append(resBundle.getString("top_RIGHT")); 197 buffer.append("\"></td>"); 198 199 buffer.append("</tr>"); 200 201 buffer.append("<tr>"); 203 204 buffer.append("<td width=\""); 205 buffer.append(bg_width); 206 buffer.append("\" background=\""); 207 buffer.append(resBundle.getString("left")); 208 buffer.append("\" style=\"background-repeat:repeat-y;\"> </td>"); 209 210 buffer.append("<td><table cellspacing=0 cellpadding=0 border=0 width=100%>\n"); 211 } 212 public int doStartLayoutTag() throws JspException { 213 StringBuffer buffer = new StringBuffer (); 214 doStartPanel(buffer); 215 doBeforeBody(buffer); 216 TagUtils.write(pageContext,buffer.toString()); 217 return EVAL_BODY_INCLUDE; 218 } 219 public void release() { 220 super.release(); 221 cols = 2; 222 width= null; 223 align ="center"; 224 } 225 228 public void setAlign(String align) { 229 this.align = align; 230 } 231 235 public void setCols(int cols) { 236 this.cols = cols; 237 } 238 242 public void setWidth(String width) { 243 if (!width.equals("0")) this.width = width; 244 else this.width=null; 245 } 246 } 247 | Popular Tags |