KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > facelets > component > RepeatRenderer


1 package com.sun.facelets.component;
2
3 import java.io.IOException JavaDoc;
4 import java.util.Iterator JavaDoc;
5 import java.util.Map JavaDoc;
6
7 import javax.faces.component.UIComponent;
8 import javax.faces.context.FacesContext;
9 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) throws IOException JavaDoc {
22         
23     }
24
25     public void encodeChildren(FacesContext context, UIComponent component) throws IOException JavaDoc {
26         if (component.getChildCount() > 0) {
27             Map JavaDoc a = component.getAttributes();
28             String JavaDoc tag = (String JavaDoc) a.get("alias.element");
29             if (tag != null) {
30                 ResponseWriter out = context.getResponseWriter();
31                 out.startElement(tag, component);
32                 String JavaDoc[] attrs = (String JavaDoc[]) a.get("alias.attributes");
33                 String JavaDoc attr;
34                 if (attrs != null) {
35                     for (int i = 0; i < attrs.length; i++) {
36                         attr = attrs[i];
37                         if ("styleClass".equals(attr)) {
38                             attr = "class";
39                         }
40                         out.writeAttribute(attr, a.get(attrs[i]), attrs[i]);
41                     }
42                 }
43             }
44             
45             Iterator JavaDoc itr = component.getChildren().iterator();
46             UIComponent c;
47             while (itr.hasNext()) {
48                 c = (UIComponent) itr.next();
49                 if (FacesAPI.getVersion() >= 12) {
50                     c.encodeAll(context);
51                 } else {
52                     ComponentSupport.encodeRecursive(context, c);
53                 }
54             }
55             
56             if (tag != null) {
57                 context.getResponseWriter().endElement(tag);
58             }
59         }
60     }
61
62     public void encodeEnd(FacesContext context, UIComponent component) throws IOException JavaDoc {
63       
64     }
65     
66     public boolean getRendersChildren() {
67         return true;
68     }
69
70 }
71
Popular Tags