1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.component; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.util.Map; |
23 | |
|
24 | |
import javax.faces.component.UIComponent; |
25 | |
import javax.faces.context.FacesContext; |
26 | |
import javax.faces.context.ResponseWriter; |
27 | |
import javax.faces.render.Renderer; |
28 | |
|
29 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer; |
30 | |
|
31 | |
@JSFRenderer(family="facelets", |
32 | |
renderKitId="HTML_BASIC", |
33 | |
type="facelets.ui.Repeat") |
34 | |
public class RepeatRenderer extends Renderer |
35 | |
{ |
36 | |
|
37 | |
public RepeatRenderer() |
38 | |
{ |
39 | 0 | super(); |
40 | 0 | } |
41 | |
|
42 | |
@Override |
43 | |
public void encodeBegin(FacesContext context, UIComponent component) throws IOException |
44 | |
{ |
45 | |
|
46 | 0 | } |
47 | |
|
48 | |
@Override |
49 | |
public void encodeChildren(FacesContext context, UIComponent component) throws IOException |
50 | |
{ |
51 | 0 | if (component.getChildCount() > 0) |
52 | |
{ |
53 | 0 | Map<String, Object> a = component.getAttributes(); |
54 | 0 | String tag = (String) a.get("alias.element"); |
55 | 0 | if (tag != null) |
56 | |
{ |
57 | 0 | ResponseWriter out = context.getResponseWriter(); |
58 | 0 | out.startElement(tag, component); |
59 | 0 | String[] attrs = (String[]) a.get("alias.attributes"); |
60 | |
String attr; |
61 | 0 | if (attrs != null) |
62 | |
{ |
63 | 0 | for (int i = 0; i < attrs.length; i++) |
64 | |
{ |
65 | 0 | attr = attrs[i]; |
66 | 0 | if ("styleClass".equals(attr)) |
67 | |
{ |
68 | 0 | attr = "class"; |
69 | |
} |
70 | 0 | out.writeAttribute(attr, a.get(attrs[i]), attrs[i]); |
71 | |
} |
72 | |
} |
73 | |
} |
74 | |
|
75 | 0 | for (int i = 0, childCount = component.getChildCount(); i < childCount; i++) |
76 | |
{ |
77 | 0 | UIComponent child = component.getChildren().get(i); |
78 | 0 | child.encodeAll(context); |
79 | |
} |
80 | |
|
81 | 0 | if (tag != null) |
82 | |
{ |
83 | 0 | context.getResponseWriter().endElement(tag); |
84 | |
} |
85 | |
} |
86 | 0 | } |
87 | |
|
88 | |
@Override |
89 | |
public void encodeEnd(FacesContext context, UIComponent component) throws IOException |
90 | |
{ |
91 | |
|
92 | 0 | } |
93 | |
|
94 | |
@Override |
95 | |
public boolean getRendersChildren() |
96 | |
{ |
97 | 0 | return true; |
98 | |
} |
99 | |
|
100 | |
} |