public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (!RenderKitUtils.assertValid(context, component)) {
return;
}
final ResponseWriter writer = context.getResponseWriter();
final UIPanelBox uipb = (UIPanelBox) component;
if (!uipb.isRendered()) {
return;
}
String dimensions = "";
if (uipb.getHeight() > 0) {
dimensions = "height:" + uipb.getHeight() + "px;";
}
if (uipb.getWidth() > 0) {
dimensions += "width:" + uipb.getWidth() + "px;";
}
//Main
writer.startElement("div", uipb);
writer.writeAttribute("class", PANELBOX_STYLE + " " + uipb.getStyle(), null);
writer.writeAttribute("style", dimensions + " " + uipb.getStyle(), null);
//Header
writer.startElement("div", uipb);
writer.writeAttribute("class", PANELBOXHEADER_STYLE + " " + uipb.getHeaderStyleClass(), null);
writer.writeAttribute("style", uipb.getHeaderStyle(), null);
writer.startElement("div", uipb);
writer.writeAttribute("class", PANELBOXHEADERCONTENT_STYLE, null);
writer.writeAttribute("style", uipb.getHeaderStyle(), null);
if (uipb.isCollapsible()) {
writer.startElement("div", uipb);
writer.writeAttribute("class", PANELBOXTOOLBOX_STYLE, null);
writer.startElement("div", uipb);
writer.writeAttribute("id", BUT_PREFIXID + uipb.getId(), null);
writer.writeAttribute("style", PANELBOX_BUTTON_SIZE, null);
if (uipb.isCollapseByDefault()) {
writer.writeAttribute("class", PANELBOX_BUTTON_EXP_STYLE, null);
} else {
writer.writeAttribute("class", PANELBOX_BUTTON_COLL_STYLE, null);
}
writer.endElement("div");
writer.endElement("div");
}
if (uipb.getTitle() != null) {
writer.startElement("span", uipb);
writer.write(uipb.getTitle());
writer.endElement("span");
} else if (uipb.getValueExpression("title") != null) {
String titleValue = uipb.getValueExpression("title").getExpressionString();
ValueExpression ve = context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(), titleValue, java.lang.String.class);
String title = (String) ve.getValue(context.getELContext());
writer.startElement("span", uipb);
writer.write(title);
writer.endElement("span");
}
writer.endElement("div");
writer.endElement("div");
//Content
writer.startElement("div", uipb);
writer.writeAttribute("id", CONTENT_PREFIXID + uipb.getId(), null);
if (uipb.isCollapseByDefault()) {
writer.writeAttribute("style", "display:none; " + uipb.getContentStyle(), null);
} else {
writer.writeAttribute("style", uipb.getContentStyle(), null);
}
writer.writeAttribute("class", PANELBOXCONTENT_STYLE + " " + uipb.getContentStyleClass(), null);
}