1/*2 * $Id: DefinitionAttributeRenderer.java 821299 2009-10-03 12:15:05Z 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 */21package org.apache.tiles.renderer.impl;
2223import java.io.IOException;
2425import org.apache.tiles.Attribute;
26import org.apache.tiles.TilesContainer;
27import org.apache.tiles.awareness.TilesContainerAware;
28import org.apache.tiles.context.TilesRequestContext;
2930/***31 * Renders an attribute that contains a reference to a definition.32 *33 * @version $Rev: 821299 $ $Date: 2009-10-03 14:15:05 +0200 (sab, 03 ott 2009) $34 * @since 2.1.035 */36publicclassDefinitionAttributeRendererextends37AbstractTypeDetectingAttributeRenderer implements TilesContainerAware {
3839/***40 * The Tiles container.41 *42 * @since 2.1.043 */44protected TilesContainer container;
4546/*** {@inheritDoc} */47publicvoid setContainer(TilesContainer container) {
48this.container = container;
49 }
5051/*** {@inheritDoc} */52 @Override
53publicvoid write(Object value, Attribute attribute,
54TilesRequestContext request)
55 throws IOException {
56 container.render(value.toString(), request.getRequestObjects());
57 }
5859/*** {@inheritDoc} */60publicboolean isRenderable(Object value, Attribute attribute,
61TilesRequestContext request) {
62if (value instanceof String) {
63return container.isValidDefinition((String) value, request
64 .getRequestObjects());
65 }
66return false;
67 }
68 }