1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.bean;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.jelly.JellyTagException;
22 import org.apache.commons.jelly.TagSupport;
23 import org.apache.commons.jelly.XMLOutput;
24 import org.apache.commons.jelly.impl.CollectionTag;
25
26 /***
27 * A simple tag which demonstrates how to process beans generically.
28 *
29 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
30 * @version $Revision: 155420 $
31 */
32 public class MyContainerTag extends TagSupport implements CollectionTag {
33
34 private List list = new ArrayList();
35 private String var;
36
37 public MyContainerTag() {
38 }
39
40
41
42 public void doTag(XMLOutput output) throws JellyTagException {
43 invokeBody(output);
44 context.setVariable(var, list);
45 list = new ArrayList();
46 }
47
48
49
50 public void addItem(Object value) {
51 list.add(value);
52 }
53
54
55
56 /***
57 * @return String
58 */
59 public String getVar() {
60 return var;
61 }
62
63 /***
64 * Sets the var.
65 * @param var The var to set
66 */
67 public void setVar(String var) {
68 this.var = var;
69 }
70
71 }