| 1 package fr.improve.struts.taglib.layout; 2 3 import javax.servlet.jsp.JspException ; 4 5 import fr.improve.struts.taglib.layout.event.EndLayoutEvent; 6 import fr.improve.struts.taglib.layout.event.LayoutEventListener; 7 import fr.improve.struts.taglib.layout.event.StartLayoutEvent; 8 import fr.improve.struts.taglib.layout.util.LayoutUtils; 9 import fr.improve.struts.taglib.layout.util.TagUtils; 10 14 public class RowTag extends LayoutTagSupport implements LayoutEventListener { 15 boolean first = true; 16 protected boolean space = true; 17 protected String width; 18 protected String styleClass; 19 20 23 public int doEndLayoutTag() throws JspException { 24 TagUtils.write(pageContext, "</tr></table>"); 25 new EndLayoutEvent(this, "</td>").send(); 26 first = true; 27 return EVAL_PAGE; 28 } 29 30 33 public void doPrintSeparator(StringBuffer buffer) { 34 if (space) { 35 buffer.append("<td> </td>\n"); 36 } 37 } 38 41 public int doStartLayoutTag() throws JspException { 42 int lc_span = LayoutUtils.getSkin(pageContext.getSession()).getFieldInterface().getColumnNumber(); 43 new StartLayoutEvent(this, "<td colspan=\"" + lc_span + "\">").send(); 44 TagUtils.write(pageContext, "<table"); 45 if (styleClass==null) { 46 TagUtils.write(pageContext, " border=\"0\""); 47 } 48 if (width!=null) { 49 TagUtils.write(pageContext, " width=\""); 50 TagUtils.write(pageContext, width); 51 TagUtils.write(pageContext, "\""); 52 } 53 if (styleClass!=null) { 54 TagUtils.write(pageContext, " class=\""); 55 TagUtils.write(pageContext, styleClass); 56 TagUtils.write(pageContext, "\""); 57 } 58 TagUtils.write(pageContext, "><tr>"); 59 return EVAL_BODY_INCLUDE; 60 } 61 public Object processStartLayoutEvent(StartLayoutEvent in_event) throws JspException { 62 StringBuffer lc_buffer = new StringBuffer (""); 63 if (first) { 64 first = false; 65 } else { 66 doPrintSeparator(lc_buffer); 67 } 68 return in_event.consume(pageContext, lc_buffer.toString()); 69 } 70 public Object processEndLayoutEvent(EndLayoutEvent in_event) throws JspException { 71 return in_event.consume(pageContext, ""); 72 } 73 74 public void release() { 75 space = true; 76 width = null; 77 styleClass = null; 78 } 79 80 public void setSpace(boolean in_space) { 81 space = in_space; 82 } 83 84 public void setWidth(String width) { 85 this.width = width; 86 } 87 88 public void setStyleClass(String styleClass) { 89 this.styleClass = styleClass; 90 } 91 } 92 | Popular Tags |