@Override
public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
// UIPanel or UICell (deprecated)
final AbstractUIPanel panel = (AbstractUIPanel) component;
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
final String clientId = panel.getClientId(facesContext);
writer.startElement(HtmlElements.DIV, panel);
HtmlRendererUtils.renderDojoDndItem(panel, writer, true);
writer.writeIdAttribute(clientId);
writer.writeClassAttribute(Classes.create(panel));
HtmlRendererUtils.writeDataAttributes(facesContext, writer, panel);
final Style style = new Style(facesContext, panel);
// XXX hotfix for panels in sheets
if (style.getPosition() == null) {
style.setPosition(Position.RELATIVE);
}
writer.writeStyleAttribute(style);
if (panel instanceof UIPanel && ((UIPanel) panel).getTip() != null) {
writer.writeAttribute(HtmlAttributes.TITLE, ((UIPanel) panel).getTip(), true);
}
// TODO check ajax id?
if (!FacesContextUtils.isAjax(facesContext)) {
final UIComponent facetReload = panel.getFacet(Facets.RELOAD);
if (facetReload != null && facetReload instanceof UIReload && facetReload.isRendered()) {
final UIReload update = (UIReload) facetReload;
writer.writeAttribute(DataAttributes.RELOAD, Integer.toString(update.getFrequency()), false);
}
}
HtmlRendererUtils.renderCommandFacet(panel, facesContext, writer);
HtmlRendererUtils.encodeContextMenu(facesContext, writer, panel);
//HtmlRendererUtils.checkForCommandFacet(panel, facesContext, writer);
final Measure borderLeft = panel.getBorderLeft();
final Measure borderRight = panel.getBorderRight();
final Measure borderTop = panel.getBorderTop();
final Measure borderBottom = panel.getBorderBottom();
if (borderLeft.greaterThan(Measure.ZERO) || borderRight.greaterThan(Measure.ZERO)
|| borderTop.greaterThan(Measure.ZERO) || borderBottom.greaterThan(Measure.ZERO)) {
writer.startElement(HtmlElements.DIV, panel);
writer.writeClassAttribute(Classes.create(panel, "content")); // needed to be scrollable inside of the panel