1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.shared.renderkit.html;
20
21 import org.apache.myfaces.shared.renderkit.RendererUtils;
22
23 import javax.faces.component.UIComponent;
24 import javax.faces.component.UIViewRoot;
25 import javax.faces.component.html.HtmlPanelGroup;
26 import javax.faces.context.FacesContext;
27 import javax.faces.context.ResponseWriter;
28 import java.io.IOException;
29
30
31
32
33
34
35
36 public class HtmlGroupRendererBase
37 extends HtmlRenderer
38 {
39 private static final String LAYOUT_BLOCK_VALUE = "block";
40
41 public boolean getRendersChildren()
42 {
43 return true;
44 }
45
46 public void encodeBegin(FacesContext context, UIComponent component)
47 throws IOException
48 {
49 }
50
51 public void encodeChildren(FacesContext context, UIComponent component)
52 throws IOException
53 {
54 }
55
56 public void encodeEnd(FacesContext context, UIComponent component)
57 throws IOException
58 {
59 ResponseWriter writer = context.getResponseWriter();
60 boolean span = false;
61
62
63 String layoutElement = HTML.SPAN_ELEM;
64
65 HtmlPanelGroup panelGroup = (HtmlPanelGroup) component;
66
67
68 String layout = panelGroup.getLayout();
69 if (layout != null && layout.equals(LAYOUT_BLOCK_VALUE))
70 {
71 layoutElement = HTML.DIV_ELEM;
72 }
73
74 if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
75 {
76 span = true;
77
78 writer.startElement(layoutElement, component);
79
80 HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
81
82 if (isCommonPropertiesOptimizationEnabled(context))
83 {
84 CommonPropertyUtils.renderCommonPassthroughProperties(writer,
85 CommonPropertyUtils.getCommonPropertiesMarked(component), component);
86 }
87 else
88 {
89 HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
90 }
91 }
92 else
93 {
94 if (isCommonPropertiesOptimizationEnabled(context))
95 {
96 long commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
97 if (commonPropertiesMarked > 0)
98 {
99 span = true;
100 writer.startElement(layoutElement, component);
101 HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
102
103 CommonPropertyUtils.renderCommonPassthroughProperties(writer, commonPropertiesMarked, component);
104 }
105 }
106 else
107 {
108 span=HtmlRendererUtils.renderHTMLAttributesWithOptionalStartElement(writer,
109 component,
110 layoutElement,
111 HTML.COMMON_PASSTROUGH_ATTRIBUTES);
112 }
113 }
114
115 RendererUtils.renderChildren(context, component);
116 if (span)
117 {
118 writer.endElement(layoutElement);
119 }
120 }
121
122 }