KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > ui > common > component > SelfRenderingComponent


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.web.ui.common.component;
18
19 import java.io.IOException JavaDoc;
20
21 import javax.faces.component.UIComponentBase;
22 import javax.faces.context.ResponseWriter;
23
24
25 /**
26  * @author kevinr
27  */

28 public abstract class SelfRenderingComponent extends UIComponentBase
29 {
30    /**
31     * Default Constructor
32     */

33    public SelfRenderingComponent()
34    {
35       // specifically set the renderer type to null to indicate to the framework
36
// that this component renders itself - there is no abstract renderer class
37
setRendererType(null);
38    }
39    
40    /**
41     * Helper to output an attribute to the output stream
42     *
43     * @param out ResponseWriter
44     * @param attr attribute value object (cannot be null)
45     * @param mapping mapping to output as e.g. style="..."
46     *
47     * @throws IOException
48     */

49    protected static void outputAttribute(ResponseWriter out, Object JavaDoc attr, String JavaDoc mapping)
50       throws IOException JavaDoc
51    {
52       if (attr != null)
53       {
54          out.write(' ');
55          out.write(mapping);
56          out.write("=\"");
57          out.write(attr.toString());
58          out.write('"');
59       }
60    }
61 }
62
Popular Tags