Skip to content

Commit 0dbcda0

Browse files
committed
Added some documentation on how Adaptive Forms submission handling works
1 parent 03d04b8 commit 0dbcda0

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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

Comments
 (0)