1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.tiles.jsp.taglib;
23
24 import org.apache.tiles.Attribute;
25 import org.apache.tiles.Attribute.AttributeType;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30 import javax.servlet.jsp.JspException;
31
32 /***
33 * PutList tag implementation.
34 *
35 * @since Tiles 1.0
36 * @version $Rev: 727715 $ $Date: 2008-12-18 14:06:06 +0100 (Thu, 18 Dec 2008) $
37 */
38 public class PutListAttributeTag extends PutAttributeTag
39 implements AddAttributeTagParent {
40
41 /***
42 * Get list defined in tag.
43 *
44 * @return The value of this list attribute.
45 */
46 @SuppressWarnings("unchecked")
47 public List<Attribute> getAttributes() {
48 return (List<Attribute>) super.getValue();
49 }
50
51 /*** {@inheritDoc} */
52 @Override
53 public void setValue(Object object) {
54 throw new IllegalStateException("The value of the PutListAttributeTag must be the originally defined list.");
55 }
56
57 /*** {@inheritDoc} */
58 @Override
59 public int doStartTag() throws JspException {
60 super.setValue(new ArrayList<Attribute>());
61 return super.doStartTag();
62 }
63
64 /***
65 * PutListAttributeTag may not have any body, except for PutAttribute tags.
66 *
67 * @return <code>SKIP_BODY</code>.
68 * @throws JspException if a JSP exception has occurred
69 */
70 public int doAfterBody() throws JspException {
71 return (SKIP_BODY);
72 }
73
74 /*** {@inheritDoc} */
75 @Override
76 protected void reset() {
77 super.reset();
78 }
79
80 /***
81 * Process nested ≶putAttribute> tag.
82 * <p/>
83 * Places the value of the nested tag within the
84 * {@link org.apache.tiles.AttributeContext}.It is the responsibility
85 * of the descendent to check security. Tags extending
86 * the {@link org.apache.tiles.jsp.taglib.ContainerTagSupport} will automatically provide
87 * the appropriate security.
88 *
89 * @param nestedTag the put tag desciendent.
90 */
91 public void processNestedTag(AddAttributeTag nestedTag) {
92 Attribute attribute = new Attribute(
93 nestedTag.getValue(), nestedTag.getRole(),
94 AttributeType.getType(nestedTag.getType()));
95
96 this.addValue(attribute);
97 }
98
99 /***
100 * Adds an attribute value to the list.
101 *
102 * @param attribute The attribute to add.
103 */
104 private void addValue(Attribute attribute) {
105 this.getAttributes().add(attribute);
106 }
107 }