1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.custom.div;
20
21 import java.io.IOException;
22
23 import javax.faces.component.UIComponent;
24 import javax.faces.context.FacesContext;
25 import javax.faces.context.ResponseWriter;
26
27 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
28 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
29 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
30
31 import org.apache.myfaces.custom.htmlTag.HtmlTagRenderer;
32
33 /**
34 * @JSFRenderer
35 * renderKitId = "HTML_BASIC"
36 * family = "javax.faces.Output"
37 * type = "org.apache.myfaces.DivRenderer"
38 * @since 1.1.7
39 * @author bdudney (latest modification by $Author: lu4242 $)
40 * @version $Revision: 691871 $ $Date: 2008-09-03 23:32:08 -0500 (Wed, 03 Sep 2008) $
41 */
42 public class DivRenderer extends HtmlTagRenderer
43 {
44 public static final String RENDERER_TYPE = "org.apache.myfaces.HtmlTagRenderer";
45
46 public void encodeBegin(FacesContext context, UIComponent component)
47 throws IOException
48 {
49 if ((context == null) || (component == null))
50 {
51 throw new NullPointerException();
52 }
53
54 super.encodeBegin(context, component);
55
56 Div div = (Div) component;
57
58 if (div.isRendered())
59 {
60 ResponseWriter writer = context.getResponseWriter();
61 //Previously, style and styleClass was rendered,
62 //so on div renderer we need to add event and universal
63 //attributes only
64 HtmlRendererUtils.renderHTMLAttributes(writer, div,
65 HTML.COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE);
66 }
67 }
68
69 }