1/*2 * $Id: PutListAttributeTag.java 727715 2008-12-18 13:06:06Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122package org.apache.tiles.jsp.taglib;
2324import org.apache.tiles.Attribute;
25import org.apache.tiles.Attribute.AttributeType;
2627import java.util.ArrayList;
28import java.util.List;
2930import javax.servlet.jsp.JspException;
3132/***33 * PutList tag implementation.34 *35 * @since Tiles 1.036 * @version $Rev: 727715 $ $Date: 2008-12-18 14:06:06 +0100 (Thu, 18 Dec 2008) $37 */38publicclassPutListAttributeTagextendsPutAttributeTag39 implements AddAttributeTagParent {
4041/***42 * Get list defined in tag.43 *44 * @return The value of this list attribute.45 */46 @SuppressWarnings("unchecked")
47public List<Attribute> getAttributes() {
48return (List<Attribute>) super.getValue();
49 }
5051/*** {@inheritDoc} */52 @Override
53publicvoid setValue(Object object) {
54thrownew IllegalStateException("The value of the PutListAttributeTag must be the originally defined list.");
55 }
5657/*** {@inheritDoc} */58 @Override
59publicint doStartTag() throws JspException {
60super.setValue(new ArrayList<Attribute>());
61returnsuper.doStartTag();
62 }
6364/***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 occurred69 */70publicint doAfterBody() throws JspException {
71return (SKIP_BODY);
72 }
7374/*** {@inheritDoc} */75 @Override
76protectedvoid reset() {
77super.reset();
78 }
7980/***81 * Process nested ≶putAttribute> tag.82 * <p/>83 * Places the value of the nested tag within the84 * {@link org.apache.tiles.AttributeContext}.It is the responsibility85 * of the descendent to check security. Tags extending86 * the {@link org.apache.tiles.jsp.taglib.ContainerTagSupport} will automatically provide87 * the appropriate security.88 *89 * @param nestedTag the put tag desciendent.90 */91publicvoid processNestedTag(AddAttributeTag nestedTag) {
92 Attribute attribute = new Attribute(
93 nestedTag.getValue(), nestedTag.getRole(),
94 AttributeType.getType(nestedTag.getType()));
9596this.addValue(attribute);
97 }
9899/***100 * Adds an attribute value to the list.101 *102 * @param attribute The attribute to add.103 */104privatevoid addValue(Attribute attribute) {
105this.getAttributes().add(attribute);
106 }
107 }