public String render()
{
String xhtml;
String xitem;
FormField field;
TemplateControl ctrl;
Iterator<FormField> it;
// Si no tiene grupos, no representa el control
if (groups.isEmpty())
{
return "<-- FormControl placeholder (void) -->\n";
}
// Obtiene la plantilla y la parte del control
ctrl = getWorkspace().getTemplate().getControl(FormControl.CTUID);
// Genera la cabecera del formulario
xhtml = "";
xitem = ctrl.getElement(CPART_HEADER);
xitem = Control.replaceTag(xitem, TAG_TITLE, this.getTitle());
xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, this.getDescription());
xitem = Control.replaceTag(xitem, TAG_FORM_NAME, this.getName());
xitem = Control.replaceTag(xitem, TAG_FORM_METHOD, "POST");
xhtml += xitem;
for (FormFieldHidden hfield : this.hidden)
{
xhtml += hfield.render(getWorkspace()) + "\n";
}
for (FormFieldset group : this.groups)
{
xitem = ctrl.getElement(CPART_GROUP_HEADER);
xitem = Control.replaceTag(xitem, TAG_TITLE, group.getTitle());
xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, group.getDescription());
xhtml += xitem;
it = group.getFields();
while (it.hasNext())
{
field = it.next();
if (field instanceof FormFieldText)
{
xitem = ctrl.getElement(CPART_FIELD_CONTROL);
xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldText) field).getLabel());
xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldText) field).getDescription());
xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldText) field).getName());
xhtml += xitem;
}
else if (field instanceof FormFieldTextArea)
{
xitem = ctrl.getElement(CPART_FIELD_TEXTAREA);
xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldTextArea) field).getLabel());
xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldTextArea) field).getDescription());
xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldTextArea) field).getName());
xhtml += xitem;
}
else if (field instanceof FormFieldInteger)
{
xitem = ctrl.getElement(CPART_FIELD_CONTROL);
xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldInteger) field).getLabel());
xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldInteger) field).getDescription());
xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldInteger) field).getName());
xhtml += xitem;
}
else if (field instanceof FormFieldBoolean)
{
xitem = ctrl.getElement(CPART_FIELD_OPTION);
xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldBoolean) field).getLabel());
xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldBoolean) field).getDescription());
xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldBoolean) field).getName());
xhtml += xitem;
}
else if (field instanceof FormFieldDate)
{
xitem = ctrl.getElement(CPART_FIELD_CONTROL);
xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldDate) field).getLabel());
xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldDate) field).getDescription());
xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldDate) field).getName());
xhtml += xitem;
}
else if (field instanceof FormFieldList)
{
xitem = ctrl.getElement(CPART_FIELD_CONTROL);
xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldList) field).getLabel());
xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldList) field).getDescription());
xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldList) field).getName());
xhtml += xitem;
}
}
xitem = ctrl.getElement(CPART_GROUP_FOOTER);
xhtml += xitem;
}
xitem = ctrl.getElement(CPART_BUTTONS);
xitem = Control.replaceTag(xitem, TAG_BUTTONS, getButtonsXhtml(getWorkspace().getServerSession()));
xhtml += xitem;
xitem = ctrl.getElement(CPART_FOOTER);
xitem = Control.replaceTag(xitem, TAG_FORM_NAME, this.name);
xhtml += xitem;
return xhtml;
}