@Override
public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException {
super.encodeBegin(facesContext, uiComponent);
AUICol auiCol = (AUICol) uiComponent;
ResponseWriter responseWriter = facesContext.getResponseWriter();
responseWriter.startElement(StringPool.DIV, uiComponent);
String id = auiCol.getClientId(facesContext);
responseWriter.writeAttribute(StringPool.ID, id, null);
StringBuilder classNames = new StringBuilder();
Integer width = auiCol.getWidth();
Integer span = auiCol.getSpan();
if (span != null) {
if ((span < 1) || (span > AUICol.COLUMNS)) {
throw new IOException("span number must be between 1 and " + AUICol.COLUMNS);
}
}
if (width != null) {
if ((width < 1) || (width > 100)) {
throw new IOException("width must be between 1 and 100");
}
span = getColumnUnitSize(width);
}
classNames.append(StringPool.SPAN);
classNames.append(span);
Integer offsetWidth = auiCol.getOffsetWidth();
Integer offset = auiCol.getOffset();
if (offset != null) {
if ((offset < 1) || (offset > AUICol.COLUMNS)) {
throw new IOException("offset must be between 1 and " + AUICol.COLUMNS);
}
}
if (offsetWidth != null) {
if ((offsetWidth < 1) || (offsetWidth > 100)) {
throw new IOException("offsetWidth must be between 1 and 100");
}
offset = getColumnUnitSize(offsetWidth);
}
if (offset != null) {
classNames.append(" aui-offset");
classNames.append(offset);
}
String cssClass = auiCol.getCssClass();
if ((cssClass != null) && (cssClass.length() > 0)) {
classNames.append(StringPool.SPACE);
classNames.append(cssClass);
}
String styleClass = auiCol.getStyleClass();
if ((styleClass != null) && (styleClass.length() > 0)) {
classNames.append(StringPool.SPACE);
classNames.append(styleClass);
}
responseWriter.writeAttribute(StringPool.CLASS, classNames.toString(), null);
Boolean first = auiCol.isFirst();
if (first != null) {
responseWriter.writeAttribute("first", first.toString(), null);
}
Boolean last = auiCol.isLast();
if (last != null) {
responseWriter.writeAttribute("last", last.toString(), null);
}
}