01: package ru.emdev.EmForge.web.renderer;
02:
03: import java.io.IOException;
04:
05: import javax.faces.component.UIComponent;
06: import javax.faces.context.FacesContext;
07: import javax.faces.context.ResponseWriter;
08:
09: import org.ajax4jsf.renderkit.ComponentVariables;
10: import org.richfaces.component.UIPanel;
11:
12: public class EmForgePanelRenderer extends
13: org.richfaces.renderkit.html.PanelRenderer {
14:
15: private String convertToString(Object obj) {
16: return (obj == null ? "" : obj.toString());
17: }
18:
19: /** We reimplement encoding method to use fieldset as frame and label as header */
20: @Override
21: public void doEncodeBegin(ResponseWriter writer,
22: FacesContext context, UIPanel component,
23: ComponentVariables variables) throws IOException {
24: java.lang.String clientId = component.getClientId(context);
25: writer.startElement("fieldset", component);
26: getUtils().writeAttribute(
27: writer,
28: "class",
29: "emforge-panel "
30: + convertToString(component.getAttributes()
31: .get("styleClass")));
32: getUtils().writeAttribute(writer, "id", clientId);
33:
34: // pass thru attributes
35: //
36: getUtils().encodeAttributesFromArray(
37: context,
38: component,
39: new String[] { "dir", "lang", "onclick", "ondblclick",
40: "onkeydown", "onkeypress", "onkeyup",
41: "onmousedown", "onmousemove", "onmouseout",
42: "onmouseover", "onmouseup", "style", "title",
43: "xml:lang" });
44: //
45: //
46: //
47:
48: if (component.getFacet("header") != null
49: && component.getFacet("header").isRendered()) {
50:
51: writer.startElement("legend", component);
52: getUtils().writeAttribute(
53: writer,
54: "class",
55: "emforge-panel-header "
56: + convertToString(component.getAttributes()
57: .get("headerClass")));
58: getUtils().writeAttribute(writer, "id",
59: convertToString(clientId) + "_header");
60:
61: UIComponent indexChildren_1 = component.getFacet("header");
62: if (null != indexChildren_1 && indexChildren_1.isRendered()) {
63: renderChild(context, indexChildren_1);
64: }
65:
66: writer.endElement("legend");
67:
68: } else if (null != component.getHeader()
69: && !"".equals(component.getHeader())) {
70:
71: writer.startElement("legend", component);
72: getUtils().writeAttribute(
73: writer,
74: "class",
75: "emforge-panel-header "
76: + convertToString(component.getAttributes()
77: .get("headerClass")));
78: getUtils().writeAttribute(writer, "id",
79: convertToString(clientId) + "_header");
80:
81: writer.writeText(convertToString(component.getAttributes()
82: .get("header")), null);
83:
84: writer.endElement("legend");
85:
86: }
87: }
88:
89: @Override
90: public void doEncodeEnd(ResponseWriter writer,
91: FacesContext context, UIPanel component,
92: ComponentVariables variables) throws IOException {
93: writer.endElement("fieldset");
94: }
95:
96: }
|