|
| 1 | +# Adaptive Form Submission Handling in fluent-forms-spring-boot-starter |
| 2 | + |
| 3 | +The submission handling code looks for one or more beans in the Spring Context that provide the |
| 4 | +`AfSubmissionHandler` interface. This interface has two methods `boolean canHandle(String formName)` |
| 5 | + and `SubmitResponse processSubmission(Submission submission)`. Whenever a submission comes in, the |
| 6 | + `canHandler` method is called on each `AfSubmissionHandler` bean – passing in the Adaptive Form’s name. |
| 7 | +The first `AfSubmissionHandler` that returns `true` (to indicate it can handle this form’s submission) |
| 8 | +will have its `processSubmission()` method called. |
| 9 | + |
| 10 | +The `processSubmission()` method receives a `Submission` object (which is populated with the submission’s |
| 11 | +information such as the form data, form name, http headers and the submission redirect URL). The |
| 12 | +`processSubmission()` method returns a `SubmitResponse` interface which contains information that will be |
| 13 | +placed in the response. It can currently be a `Response` object, a `SeeOther` object or a `Redirect` |
| 14 | +object (which all implement the `SubmitResponse` interface). A `Response` object is for returning text, |
| 15 | +html, json, etc. to the browser. A `SeeOther` will redirect the browser to perform a GET on another URL. A `Redirect` will redirect the browser to perform a POST to another URL. |
| 16 | + |
| 17 | +There are a bunch of static convenience methods in `AfSubmissionHandler` that means that you probably |
| 18 | +won’t have to create an `AfSubmissionhandler` directly, but can use a convenience method like |
| 19 | +`AfSubmissionHandler. canHandleFormNameEquals(String formName, Function<Submission, SubmitResponse> handlerLogic)` |
| 20 | +and others. |
| 21 | + |
| 22 | +There are also static convenience functions in the `SubmitResponse.Response` object that make it easy to |
| 23 | +create the most common responses (e.g. `Response json(String json)`). |
0 commit comments