01: package com.sun.facelets.component;
02:
03: import java.io.IOException;
04: import java.util.Iterator;
05: import java.util.Map;
06:
07: import javax.faces.component.UIComponent;
08: import javax.faces.context.FacesContext;
09: import javax.faces.context.ResponseWriter;
10: import javax.faces.render.Renderer;
11:
12: import com.sun.facelets.tag.jsf.ComponentSupport;
13: import com.sun.facelets.util.FacesAPI;
14:
15: public class RepeatRenderer extends Renderer {
16:
17: public RepeatRenderer() {
18: super ();
19: }
20:
21: public void encodeBegin(FacesContext context, UIComponent component)
22: throws IOException {
23:
24: }
25:
26: public void encodeChildren(FacesContext context,
27: UIComponent component) throws IOException {
28: if (component.getChildCount() > 0) {
29: Map a = component.getAttributes();
30: String tag = (String) a.get("alias.element");
31: if (tag != null) {
32: ResponseWriter out = context.getResponseWriter();
33: out.startElement(tag, component);
34: String[] attrs = (String[]) a.get("alias.attributes");
35: String attr;
36: if (attrs != null) {
37: for (int i = 0; i < attrs.length; i++) {
38: attr = attrs[i];
39: if ("styleClass".equals(attr)) {
40: attr = "class";
41: }
42: out.writeAttribute(attr, a.get(attrs[i]),
43: attrs[i]);
44: }
45: }
46: }
47:
48: Iterator itr = component.getChildren().iterator();
49: UIComponent c;
50: while (itr.hasNext()) {
51: c = (UIComponent) itr.next();
52: if (FacesAPI.getVersion() >= 12) {
53: c.encodeAll(context);
54: } else {
55: ComponentSupport.encodeRecursive(context, c);
56: }
57: }
58:
59: if (tag != null) {
60: context.getResponseWriter().endElement(tag);
61: }
62: }
63: }
64:
65: public void encodeEnd(FacesContext context, UIComponent component)
66: throws IOException {
67:
68: }
69:
70: public boolean getRendersChildren() {
71: return true;
72: }
73:
74: }
|