1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.tiles.renderer.impl;
22
23 import java.io.IOException;
24
25 import org.apache.tiles.Attribute;
26 import org.apache.tiles.TilesContainer;
27 import org.apache.tiles.awareness.TilesContainerAware;
28 import org.apache.tiles.context.TilesRequestContext;
29
30 /***
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.0
35 */
36 public class DefinitionAttributeRenderer extends
37 AbstractTypeDetectingAttributeRenderer implements TilesContainerAware {
38
39 /***
40 * The Tiles container.
41 *
42 * @since 2.1.0
43 */
44 protected TilesContainer container;
45
46 /*** {@inheritDoc} */
47 public void setContainer(TilesContainer container) {
48 this.container = container;
49 }
50
51 /*** {@inheritDoc} */
52 @Override
53 public void write(Object value, Attribute attribute,
54 TilesRequestContext request)
55 throws IOException {
56 container.render(value.toString(), request.getRequestObjects());
57 }
58
59 /*** {@inheritDoc} */
60 public boolean isRenderable(Object value, Attribute attribute,
61 TilesRequestContext request) {
62 if (value instanceof String) {
63 return container.isValidDefinition((String) value, request
64 .getRequestObjects());
65 }
66 return false;
67 }
68 }