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