KickJava   Java API By Example, From Geeks To Geeks.

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


1 package fr.improve.struts.taglib.layout.event;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import fr.improve.struts.taglib.layout.LayoutTag;
6 import fr.improve.struts.taglib.layout.util.LayoutUtils;
7 import fr.improve.struts.taglib.layout.util.ParentFinder;
8
9
10 /**
11  * This event is send by struts-layout tags to compute the number of td
12  * requires to span a component on multiple columns<br/>
13  *
14  * @author jnribette
15  */

16 public class ComputeLayoutSpanEvent extends AbstractLayoutEvent {
17     private int col;
18     
19     public ComputeLayoutSpanEvent(LayoutTag in_tag, int in_colspan) {
20         super(in_tag, null);
21         col = in_colspan;
22     }
23     /**
24      * Send the event to the parent layout tag of the event tag source.
25      * Return the td span value as an Integer.
26      */

27     public Object JavaDoc send() throws JspException JavaDoc {
28         return sendToParent(source);
29     }
30     
31     public Object JavaDoc sendToParent(LayoutTag in_tag) throws JspException JavaDoc {
32         ComputeLayoutSpanEventListener lc_listener = (ComputeLayoutSpanEventListener) ParentFinder.findLayoutTag(in_tag, ComputeLayoutSpanEventListener.class);
33   
34         if (lc_listener!=null) {
35             return lc_listener.computeColspan(this);
36         } else {
37             return consume(in_tag);
38         }
39     }
40     
41     public int getColspan() {
42         return col;
43     }
44     
45     public Object JavaDoc consume(LayoutTag in_tag) throws JspException JavaDoc {
46         int lc_colspan = LayoutUtils.getSkin(in_tag.getPageContext().getSession()).getFieldInterface().getColumnNumber() * col;
47         return new Integer JavaDoc(lc_colspan);
48     }
49 }
50
Popular Tags