}
List controls = getControls();
for (int i = 0; i < controls.size(); i++) {
Control control = (Control) controls.get(i);
// Buttons are rendered separately
if (control instanceof Button) {
continue;
}
if (!isHidden(control)) {
// Field width
Integer width = (Integer) getFieldWidths().get(control.getName());
if (column == 1) {
buffer.append("<tr class=\"fields\">\n");
openTableRow = true;
}
if (control instanceof Label) {
Label label = (Label) control;
buffer.append("<td align=\"");
buffer.append(getForm().getLabelAlign());
buffer.append("\" class=\"fields");
String cellStyleClass = label.getParentStyleClassHint();
if (cellStyleClass != null) {
buffer.append(" ");
buffer.append(cellStyleClass);
}
buffer.append("\"");
buffer.appendAttribute("style", label.getParentStyleHint());
if (width != null) {
int colspan = (width.intValue() * 2);
buffer.appendAttribute("colspan", colspan);
} else {
buffer.appendAttribute("colspan", 2);
}
if (label.hasAttributes()) {
//Temporarily remove the style attribute
String tempStyle = null;
if (label.hasAttribute("style")) {
tempStyle = label.getAttribute("style");
label.setAttribute("style", null);
}
buffer.appendAttributes(label.getAttributes());
//Put style back in attribute map
if (tempStyle != null) {
label.setAttribute("style", tempStyle);
}
}
buffer.append(">");
label.render(buffer);
buffer.append("</td>\n");
} else if (control instanceof Field) {
Field field = (Field) control;
Form form = getForm();
// Write out label
if (Form.POSITION_LEFT.equals(form.getLabelsPosition())) {
buffer.append("<td class=\"fields");
String cellStyleClass = field.getParentStyleClassHint();
if (cellStyleClass != null) {
buffer.append(" ");
buffer.append(cellStyleClass);
}
buffer.append("\"");
buffer.appendAttribute("align", form.getLabelAlign());
String cellStyle = field.getParentStyleHint();
if (cellStyle == null) {
cellStyle = form.getLabelStyle();
}
buffer.appendAttribute("style", cellStyle);
buffer.append(">");
} else {
buffer.append("<td valign=\"top\" class=\"fields");
String cellStyleClass = field.getParentStyleClassHint();
if (cellStyleClass != null) {
buffer.append(" ");
buffer.append(cellStyleClass);
}
buffer.append("\"");
String cellStyle = field.getParentStyleHint();
if (cellStyle == null) {
cellStyle = form.getLabelStyle();
}
buffer.appendAttribute("style", cellStyle);
buffer.append(">");
}
// Store the field id and label (the values could be null)
String fieldId = field.getId();
String fieldLabel = field.getLabel();
// Only render a label if the fieldId and fieldLabel is set
if (fieldId != null && fieldLabel != null) {
if (field.isRequired()) {
buffer.append(form.getMessage("label-required-prefix"));
} else {
buffer.append(form.getMessage("label-not-required-prefix"));
}
buffer.elementStart("label");
buffer.appendAttribute("for", field.getId());
buffer.appendAttribute("style", field.getLabelStyle());
if (field.isDisabled()) {
buffer.appendAttributeDisabled();
}
String cellClass = field.getLabelStyleClass();
if (field.getError() == null) {
buffer.appendAttribute("class", cellClass);
} else {
buffer.append(" class=\"error");
if (cellClass != null) {
buffer.append(" ");
buffer.append(cellClass);
}
buffer.append("\"");
}
buffer.closeTag();
buffer.append(field.getLabel());
buffer.elementEnd("label");
if (field.isRequired()) {
buffer.append(form.getMessage("label-required-suffix"));
} else {
buffer.append(form.getMessage("label-not-required-suffix"));
}
}
if (Form.POSITION_LEFT.equals(form.getLabelsPosition())) {
buffer.append("</td>\n");
buffer.append("<td");
buffer.appendAttribute("class", field.getParentStyleClassHint());
buffer.appendAttribute("align", "left");
String cellStyle = field.getParentStyleHint();
if (cellStyle == null) {
cellStyle = form.getFieldStyle();
}
buffer.appendAttribute("style", cellStyle);
if (width != null) {
int colspan = (width.intValue() * 2) - 1;
buffer.appendAttribute("colspan", colspan);
}
buffer.append(">");
} else {
buffer.append("<br/>");
}
// Write out field
field.render(buffer);
buffer.append("</td>\n");
} else {
buffer.append("<td class=\"fields\"");
if (width != null) {
int colspan = (width.intValue() * 2);
buffer.appendAttribute("colspan", colspan);
} else {
buffer.appendAttribute("colspan", 2);
}
buffer.append(">\n");
control.render(buffer);
buffer.append("</td>\n");
}
if (width != null) {