1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.shared_impl.renderkit.html; |
20 | |
|
21 | |
import org.apache.myfaces.shared_impl.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 | 0 | public class HtmlGroupRendererBase |
37 | |
extends HtmlRenderer |
38 | |
{ |
39 | |
private static final String LAYOUT_BLOCK_VALUE = "block"; |
40 | |
|
41 | |
public boolean getRendersChildren() |
42 | |
{ |
43 | 0 | return true; |
44 | |
} |
45 | |
|
46 | |
public void encodeBegin(FacesContext context, UIComponent component) |
47 | |
throws IOException |
48 | |
{ |
49 | 0 | } |
50 | |
|
51 | |
public void encodeChildren(FacesContext context, UIComponent component) |
52 | |
throws IOException |
53 | |
{ |
54 | 0 | } |
55 | |
|
56 | |
public void encodeEnd(FacesContext context, UIComponent component) |
57 | |
throws IOException |
58 | |
{ |
59 | 0 | ResponseWriter writer = context.getResponseWriter(); |
60 | 0 | boolean span = false; |
61 | |
|
62 | |
|
63 | 0 | String layoutElement = HTML.SPAN_ELEM; |
64 | |
|
65 | 0 | HtmlPanelGroup panelGroup = (HtmlPanelGroup) component; |
66 | |
|
67 | |
|
68 | 0 | String layout = panelGroup.getLayout(); |
69 | 0 | if (layout != null && layout.equals(LAYOUT_BLOCK_VALUE)) |
70 | |
{ |
71 | 0 | layoutElement = HTML.DIV_ELEM; |
72 | |
} |
73 | |
|
74 | 0 | if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) |
75 | |
{ |
76 | 0 | span = true; |
77 | |
|
78 | 0 | writer.startElement(layoutElement, component); |
79 | |
|
80 | 0 | HtmlRendererUtils.writeIdIfNecessary(writer, component, context); |
81 | |
|
82 | 0 | HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES); |
83 | |
} |
84 | |
else |
85 | |
{ |
86 | 0 | span=HtmlRendererUtils.renderHTMLAttributesWithOptionalStartElement(writer, |
87 | |
component, |
88 | |
layoutElement, |
89 | |
HTML.COMMON_PASSTROUGH_ATTRIBUTES); |
90 | |
} |
91 | |
|
92 | 0 | RendererUtils.renderChildren(context, component); |
93 | 0 | if (span) |
94 | |
{ |
95 | 0 | writer.endElement(layoutElement); |
96 | |
} |
97 | 0 | } |
98 | |
|
99 | |
} |