01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.corelib.components;
16:
17: import org.apache.tapestry.Binding;
18: import org.apache.tapestry.ComponentResources;
19: import org.apache.tapestry.MarkupWriter;
20: import org.apache.tapestry.annotations.Inject;
21: import org.apache.tapestry.annotations.Parameter;
22: import org.apache.tapestry.services.ComponentDefaultProvider;
23:
24: /**
25: * Used to output raw markup to the client. Unlike, say, an expansion, the output from OutputRaw is
26: * unfiltered, with any special characters or entities left exactly as is. This is used in
27: * situations where the markup is provided externally, rather than constructed within Tapestry.
28: *
29: * @see MarkupWriter#writeRaw(String)
30: */
31: public class OutputRaw {
32: /**
33: * The value to to render. If unbound, and a property of the container matches the component's
34: * id, then that property will be the source of the value.
35: */
36: @Parameter(required=true)
37: private String _value;
38:
39: @Inject
40: private ComponentDefaultProvider _defaultProvider;
41:
42: @Inject
43: private ComponentResources _resources;
44:
45: Binding defaultValue() {
46: return _defaultProvider.defaultBinding("value", _resources);
47: }
48:
49: boolean beginRender(MarkupWriter writer) {
50: if (_value != null && _value.length() > 0)
51: writer.writeRaw(_value);
52:
53: // Abort the rest of the render.
54:
55: return false;
56: }
57:
58: // For testing:
59:
60: void setValue(String value) {
61: _value = value;
62: }
63:
64: }
|