KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > renderkit > html > HtmlGroupRenderer


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.renderkit.html;
17
18 import org.apache.myfaces.renderkit.RendererUtils;
19
20 import javax.faces.component.UIComponent;
21 import javax.faces.component.UIViewRoot;
22 import javax.faces.context.FacesContext;
23 import javax.faces.context.ResponseWriter;
24 import java.io.IOException JavaDoc;
25
26 /**
27  * @author Thomas Spiegl (latest modification by $Author: mmarinschek $)
28  * @author Manfred Geiler
29  * @version $Revision: 1.8 $ $Date: 2004/12/23 13:03:08 $
30  */

31 public class HtmlGroupRenderer
32     extends HtmlRenderer
33 {
34     public boolean getRendersChildren()
35     {
36         return true;
37     }
38
39     public void encodeBegin(FacesContext context, UIComponent component)
40             throws IOException JavaDoc
41     {
42     }
43
44     public void encodeChildren(FacesContext context, UIComponent component)
45         throws IOException JavaDoc
46     {
47     }
48
49     public void encodeEnd(FacesContext context, UIComponent component)
50             throws IOException JavaDoc
51     {
52         ResponseWriter writer = context.getResponseWriter();
53         boolean span = false;
54
55         if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
56         {
57             span = true;
58
59             writer.startElement(HTML.SPAN_ELEM, component);
60
61             HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
62
63             HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
64         }
65         else
66         {
67             span=HtmlRendererUtils.renderHTMLAttributesWithOptionalStartElement(writer,
68                                                                              component,
69                                                                              HTML.SPAN_ELEM,
70                                                                              HTML.COMMON_PASSTROUGH_ATTRIBUTES);
71         }
72
73         RendererUtils.renderChildren(context, component);
74         if (span)
75         {
76             writer.endElement(HTML.SPAN_ELEM);
77         }
78     }
79 }
80
Popular Tags