KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > event > StartLayoutEvent


1 package fr.improve.struts.taglib.layout.event;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4 import javax.servlet.jsp.PageContext JavaDoc;
5
6 import fr.improve.struts.taglib.layout.LayoutTag;
7 import fr.improve.struts.taglib.layout.util.ParentFinder;
8 import fr.improve.struts.taglib.layout.util.TagUtils;
9
10
11 /**
12  * This event is send by struts-layout tags to their parent tags.<br/>
13  * When a parent tag process this event, he must make sure that the last HTML code that was generated is a &lt;tr&gt; tag.
14  * Th layout tag sending this event must write its output in two columns.
15  *
16  * @author jnribette
17  */

18 public class StartLayoutEvent extends AbstractLayoutEvent {
19     /**
20      * Construct a new StartLayout event.
21      * @param in_tag the tag source of the event.
22      * @param in_value HTML code to write to the out flow if the source is nested in a layout tag.
23      */

24     public StartLayoutEvent(LayoutTag in_tag, Object JavaDoc in_value) {
25         super(in_tag, in_value);
26     }
27     /**
28      * Send the event to the parent layout tag of the event tag source.
29      * If the event was succesfully processed by a parent layout tag, the method returns Boolean.TRUE.
30      */

31     public Object JavaDoc send() throws JspException JavaDoc {
32         return sendToParent(source);
33     }
34     public Object JavaDoc sendToParent(LayoutTag in_tag) throws JspException JavaDoc {
35         LayoutEventListener lc_listener = (LayoutEventListener) ParentFinder.findLayoutTag(in_tag, LayoutEventListener.class);
36         if (lc_listener!=null) {
37             return lc_listener.processStartLayoutEvent(this);
38         } else {
39             return Boolean.FALSE;
40         }
41     }
42     public Boolean JavaDoc consume(PageContext JavaDoc in_context, String JavaDoc in_start) throws JspException JavaDoc {
43     // Do write with the source tag pageContext : in the case of an include,
44
// writing with the target tag pageContext may mess the HTML.
45
if (in_start!=null) {
46             TagUtils.write(source.getPageContext(), in_start);
47         }
48         if (value!=null) {
49             TagUtils.write(source.getPageContext(),value.toString());
50         }
51         return Boolean.TRUE;
52     }
53     
54 }
55
Popular Tags