in tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java [495:616]
Object onAction(EventContext context) throws IOException
{
beforeProcessSubmit(context);
tracker.clear();
formSupport = new FormSupportImpl(resources, validationId);
environment.push(ValidationTracker.class, tracker);
environment.push(FormSupport.class, formSupport);
Heartbeat heartbeat = new HeartbeatImpl();
environment.push(Heartbeat.class, heartbeat);
heartbeat.begin();
boolean didPushBeanValidationContext = false;
try
{
resources.triggerContextEvent(EventConstants.PREPARE_FOR_SUBMIT, context, eventCallback);
if (eventCallback.isAborted())
return true;
resources.triggerContextEvent(EventConstants.PREPARE, context, eventCallback);
if (eventCallback.isAborted())
return true;
if (isFormCancelled())
{
executeStoredActions(true);
resources.triggerContextEvent(EventConstants.CANCELED, context, eventCallback);
if (eventCallback.isAborted())
return true;
}
environment.push(BeanValidationContext.class, new BeanValidationContextImpl(validate));
didPushBeanValidationContext = true;
executeStoredActions(false);
heartbeat.end();
formSupport.executeDeferred();
fireValidateEvent(EventConstants.VALIDATE, context, eventCallback);
if (eventCallback.isAborted())
{
return true;
}
afterValidate();
// Let the listeners know about overall success or failure. Most
// listeners fall into
// one of those two camps.
// If the tracker has no errors, then clear it of any input values
// as well, so that the next page render will be "clean" and show
// true persistent data, not value from the previous form
// submission.
if (!tracker.getHasErrors())
{
tracker.clear();
}
String eventType = tracker.getHasErrors()
? EventConstants.FAILURE
: EventConstants.SUCCESS;
resources.triggerContextEvent(eventType, context, eventCallback);
if (eventCallback.isAborted())
{
return true;
}
// Lastly, tell anyone whose interested that the form is completely
// submitted.
resources.triggerContextEvent(EventConstants.SUBMIT, context, eventCallback);
afterSuccessOrFailure();
if (eventCallback.isAborted())
{
return true;
}
// For traditional request with no validation exceptions, re-render the
// current page immediately, as-is. Prior to Tapestry 5.4, a redirect was
// sent that required that the tracker be persisted across requests.
// See https://issues.apache.org/jira/browse/TAP5-1808
if (tracker.getHasErrors() && !request.isXHR())
{
return STREAM_ACTIVE_PAGE_CONTENT;
}
// The event will not work its way up.
return false;
} finally
{
environment.pop(Heartbeat.class);
environment.pop(FormSupport.class);
environment.pop(ValidationTracker.class);
if (didPushBeanValidationContext)
{
environment.pop(BeanValidationContext.class);
}
}
}