KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > RowTag


1 package fr.improve.struts.taglib.layout;
2
3 import javax.servlet.jsp.JspException JavaDoc;
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 /**
11  * Allow to align more than one field on a line.
12  * @author: JeanNoel Ribette
13  */

14 public class RowTag extends LayoutTagSupport implements LayoutEventListener {
15     boolean first = true;
16     protected boolean space = true;
17     protected String JavaDoc width;
18     protected String JavaDoc styleClass;
19     
20     /**
21      * End a line of field.
22      */

23     public int doEndLayoutTag() throws JspException JavaDoc {
24         TagUtils.write(pageContext, "</tr></table>");
25         new EndLayoutEvent(this, "</td>").send();
26         first = true;
27         return EVAL_PAGE;
28     }
29     
30     /**
31      * Print an empty td (if space is set to true)
32      */

33     public void doPrintSeparator(StringBuffer JavaDoc buffer) {
34         if (space) {
35             buffer.append("<td>&nbsp;&nbsp;</td>\n");
36         }
37     }
38     /**
39      * Start a line of field.
40      */

41     public int doStartLayoutTag() throws JspException JavaDoc {
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 JavaDoc processStartLayoutEvent(StartLayoutEvent in_event) throws JspException JavaDoc {
62         StringBuffer JavaDoc lc_buffer = new StringBuffer JavaDoc("");
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 JavaDoc processEndLayoutEvent(EndLayoutEvent in_event) throws JspException JavaDoc {
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 JavaDoc width) {
85         this.width = width;
86     }
87     
88     public void setStyleClass(String JavaDoc styleClass) {
89         this.styleClass = styleClass;
90     }
91 }
92
Popular Tags