01: // Copyright 2006, 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.mixins;
16:
17: import org.apache.tapestry.ComponentResources;
18: import org.apache.tapestry.MarkupWriter;
19: import org.apache.tapestry.annotations.AfterRenderTemplate;
20: import org.apache.tapestry.annotations.BeforeRenderTemplate;
21: import org.apache.tapestry.annotations.BeginRender;
22: import org.apache.tapestry.annotations.Inject;
23: import org.apache.tapestry.annotations.MixinAfter;
24: import org.apache.tapestry.annotations.SupportsInformalParameters;
25:
26: /**
27: * Used to render out all informal parameters, in the {@link PostBeginRender} phase.
28: * <p>
29: * This mixin can be used with components that render a single tag inside the {@link BeginRender}
30: * phase. RenderInformals will activate during the PostBeginRender phase to write additional
31: * attributes, from the informal parameters, into the active element.
32: * <p>
33: * If you want this behavior, but need to render more than a single tag, then implement render phase
34: * methods for the {@link BeforeRenderTemplate} and {@link AfterRenderTemplate} phases. Use those
35: * phases to write the additional elements and close them.
36: * <p>
37: * This is often used as a base class, for cases where a component doesn't have other mixins.
38: */
39: @MixinAfter
40: @SupportsInformalParameters
41: public class RenderInformals {
42: @Inject
43: private ComponentResources _resources;
44:
45: void beginRender(MarkupWriter writer) {
46: _resources.renderInformalParameters(writer);
47: }
48: }
|