001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005//     http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5.corelib.mixins;
014
015import org.apache.tapestry5.ComponentResources;
016import org.apache.tapestry5.MarkupWriter;
017import org.apache.tapestry5.annotations.*;
018import org.apache.tapestry5.ioc.annotations.Inject;
019
020/**
021 * Used to render out all informal parameters, at the end of the {@link org.apache.tapestry5.annotations.BeginRender}
022 * phase.
023 *
024 * This mixin can be used with components that render a single tag inside the {@link BeginRender} phase. RenderInformals
025 * will activate during the PostBeginRender phase to write additional attributes, from the informal parameters, into the
026 * active element.
027 *
028 * If you want this behavior, but need to render more than a single tag, then implement render phase methods for the
029 * {@link BeforeRenderTemplate} and {@link AfterRenderTemplate} phases. Use those phases to write the additional
030 * elements and close them.
031 *
032 * This is often used as a base class, for cases where a component doesn't have other mixins.
033 * 
034 * @tapestrydoc
035 */
036@MixinAfter
037@SupportsInformalParameters
038public class RenderInformals
039{
040    @Inject
041    private ComponentResources resources;
042
043    void beginRender(MarkupWriter writer)
044    {
045        resources.renderInformalParameters(writer);
046    }
047}