}
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 class=\"fields\" align=\"");
buffer.append(getForm().getLabelAlign());
buffer.append("\"");
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\"");
buffer.appendAttribute("align", form.getLabelAlign());
buffer.appendAttribute("style", form.getLabelStyle());
buffer.append(">");
} else {
buffer.append("<td class=\"fields\" valign=\"top\"");
buffer.appendAttribute("style", form.getLabelStyle());
buffer.append(">");
}
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());
if (field.isDisabled()) {
buffer.appendAttributeDisabled();
}
if (field.getError() != null) {
buffer.appendAttribute("class", "error");
}
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 align=\"left\"");
buffer.appendAttribute("style", form.getFieldStyle());
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) {