KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > field > LineTag


1 package fr.improve.struts.taglib.layout.field;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import fr.improve.struts.taglib.layout.LayoutTagSupport;
6 import fr.improve.struts.taglib.layout.event.EndLayoutEvent;
7 import fr.improve.struts.taglib.layout.event.LayoutEventListener;
8 import fr.improve.struts.taglib.layout.event.StartLayoutEvent;
9 import fr.improve.struts.taglib.layout.util.TagUtils;
10 /**
11  * Allow to align more than one field on a line. Fields in different line tags are aligned.
12  * @author: JeanNoŽl Ribette
13  */

14 public class LineTag extends LayoutTagSupport implements LayoutEventListener {
15     protected boolean space = true;
16 /**
17  * End a line of field.
18  */

19 public int doEndLayoutTag() throws JspException JavaDoc {
20     if (Boolean.FALSE.equals(new EndLayoutEvent(this, null).send())) {
21         TagUtils.write(pageContext, "</tr>");
22     }
23     return EVAL_PAGE;
24 }
25 public void doPrintSeparator(StringBuffer JavaDoc buffer) {
26     buffer.append("<td>&nbsp;&nbsp;</td>\n");
27 }
28 /**
29  * Start a line of field.
30  */

31 public int doStartLayoutTag() throws JspException JavaDoc {
32     if (Boolean.FALSE.equals(new StartLayoutEvent(this, null).send())) {
33         TagUtils.write(pageContext, "<tr>");
34     }
35     return EVAL_BODY_INCLUDE;
36 }
37 public Object JavaDoc processStartLayoutEvent(StartLayoutEvent in_event) throws JspException JavaDoc {
38     return in_event.consume(pageContext, "");
39 }
40 public Object JavaDoc processEndLayoutEvent(EndLayoutEvent in_event) throws JspException JavaDoc {
41     StringBuffer JavaDoc lc_buffer = new StringBuffer JavaDoc();
42     if (space) {
43         doPrintSeparator(lc_buffer);
44     }
45     return in_event.consume(pageContext, lc_buffer.toString());
46 }
47     public void release() {
48         super.release();
49         space = true;
50     }
51     public void setSpace(boolean in_boolean) {
52         space = in_boolean;
53     }
54 }
55
Popular Tags