+ public static class PermamentFormException extends RuntimeException {
+
+ public PermamentFormException(GigiApiException cause) {
+ super(cause);
+ }
+
+ @Override
+ public synchronized GigiApiException getCause() {
+ return (GigiApiException) super.getCause();
+ }
+ }
+
+ /**
+ * Encapsulates a (non-failure) outcome of a form.
+ */
+ public static abstract class SubmissionResult {
+
+ public abstract boolean endsForm();
+ }
+
+ /**
+ * The form has finished and the user should see the successful completion
+ * on a regular page.
+ */
+ public static class RedirectResult extends SubmissionResult {
+
+ private final String target;
+
+ public RedirectResult(String target) {
+ this.target = target;
+ }
+
+ @Override
+ public boolean endsForm() {
+ return true;
+ }
+
+ }
+
+ /**
+ * The form has not finished and should be re-emitted, however no error
+ * occurred.
+ */
+ public static class FormContinue extends SubmissionResult {
+
+ @Override
+ public boolean endsForm() {
+ return false;
+ }
+ }
+
+ /**
+ * The form has successfully finished and a message should be emitted on a
+ * stateful page.
+ */
+ public static class SuccessMessageResult extends SubmissionResult {
+
+ private final Outputable message;
+
+ public SuccessMessageResult(Outputable message) {
+ this.message = message;
+ }
+
+ @Override
+ public boolean endsForm() {
+ return true;
+ }
+ }
+