001    // Copyright 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    
015    package org.apache.tapestry5.corelib.components;
016    
017    import org.apache.tapestry5.MarkupWriter;
018    import org.apache.tapestry5.annotations.Parameter;
019    import org.apache.tapestry5.corelib.pages.ExceptionReport;
020    import org.apache.tapestry5.ioc.annotations.Inject;
021    import org.apache.tapestry5.ioc.annotations.Primary;
022    import org.apache.tapestry5.services.ObjectRenderer;
023    
024    /**
025     * Renders out an object using the @{@link Primary} {@link ObjectRenderer} service. Used primarily on the
026     * {@link ExceptionReport} page.
027     * This is focused on objects that have a specific {@link ObjectRenderer} strategy. The {@link BeanDisplay} component is
028     * used for displaying the contents of arbitrary objects in terms of a series of property names and values.
029     * 
030     * @tapestrydoc
031     */
032    public class RenderObject
033    {
034        @Parameter(required = true)
035        private Object object;
036    
037        @Inject
038        @Primary
039        private ObjectRenderer<Object> renderer;
040    
041        boolean beginRender(MarkupWriter writer)
042        {
043            renderer.render(object, writer);
044    
045            return false;
046        }
047    }