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