*/
public class FlushTag extends TagSupport {
public int doEndTag() throws JspException {
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
FormsSupport support = FormsSupport.getInstance(request);
FormTag formTag = (FormTag)findAncestorWithClass(this, FormTag.class);
if (formTag == null) {
throw new JspException("Cannot get enclosing form tag");
}
String action = formTag.getAction();
FormData formData = null;
try {
formData = support.getFormData(request, action, false);
} catch (Exception e) {
throw new JspException("Cannot get form data for action '" + action + "'!");
}
if (formData instanceof FlushableForm) {
FlushableForm values = (FlushableForm)formData;
FormResult result = support.getFormResult(request, action);
if (result != null) {
try {
Iterator inputs = result.getFormInputResults();
while (inputs.hasNext()) {
FormInputResult inputResult = (FormInputResult)inputs.next();
FormInput input = inputResult.getFormInput();
Object value = inputResult.format(request);
if (input.isArray()) {
values._setInputs(input.getName(), (String[])value);
} else {
values._setInput(input.getName(), (String)value);
}
}
} catch (Exception e) {
throw new JspException(e);
}
} else {
Form form = support.getForm(request, action);
if (form == null) {
throw new JspException("Cannot find form for action '" + action + "'!");
}
try {
Iterator inputs = form.getFormInputs();