01: /*
02: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
03: * @version $Id: ContainerTag.java 6385 2007-10-25 14:02:26Z wehrens $
04: */
05: package org.gridsphere.provider.portletui.tags;
06:
07: import org.gridsphere.provider.portletui.beans.BaseComponentBean;
08: import org.gridsphere.provider.portletui.beans.BeanContainer;
09: import org.gridsphere.provider.portletui.beans.TagBean;
10:
11: import javax.servlet.jsp.JspException;
12: import java.util.ArrayList;
13: import java.util.List;
14:
15: /**
16: * The abstract <code>ContainerTag</code> provides a bean container used by other tags that are themselves containers
17: * for nested tags.
18: */
19: public abstract class ContainerTag extends BaseComponentTag {
20:
21: // make sure it is initalized, otherwise adding a tag throws NPE
22: protected List<TagBean> list = new ArrayList<TagBean>();
23:
24: /**
25: * Adds a tag bean to the container
26: *
27: * @param tagBean a tag bean
28: */
29: public void addTagBean(TagBean tagBean) {
30: list.add(tagBean);
31: }
32:
33: /**
34: * Removes a tag bean from the container
35: *
36: * @param tagBean a tag bean
37: */
38: public void removeTagBean(TagBean tagBean) {
39: list.remove(tagBean);
40: }
41:
42: /**
43: * Returns a list of tag beans
44: *
45: * @return a list of tag beans
46: */
47: public List<TagBean> getTagBeans() {
48: return list;
49: }
50:
51: public abstract int doStartTag() throws JspException;
52:
53: public abstract int doEndTag() throws JspException;
54:
55: public void doEndTag(BeanContainer beanContainer)
56: throws JspException {
57: for (TagBean tagBean : list) {
58: BaseComponentBean bc = (BaseComponentBean) tagBean;
59: beanContainer.addBean(bc);
60: }
61: }
62:
63: }
|