Skip to content

Commit 1e52f8e

Browse files
committed
Indentation
1 parent 6bc3044 commit 1e52f8e

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

_posts/2015-06-01-forms.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ You may POST Arrays, Lists, or Sets to your `RouteHandler` implementations by us
2929

3030
```html
3131
<form>
32-
<input name="rainbow[0]" value="Red">
33-
<input name="rainbow[1]" value="Orange">
34-
<input name="rainbow[2]" value="Yellow">
35-
<input name="rainbow[3]" value="Green">
36-
<input name="rainbow[4]" value="Blue">
37-
<input name="rainbow[5]" value="Indigo">
38-
<input name="rainbow[6]" value="Violet">
32+
<input name="rainbow[0]" value="Red">
33+
<input name="rainbow[1]" value="Orange">
34+
<input name="rainbow[2]" value="Yellow">
35+
<input name="rainbow[3]" value="Green">
36+
<input name="rainbow[4]" value="Blue">
37+
<input name="rainbow[5]" value="Indigo">
38+
<input name="rainbow[6]" value="Violet">
3939
</form>
4040
```
4141

4242
In this example, Pippo will automatically collect the values into a parameter named *rainbow*. The *rainbow* parameter may be accessed and transformed to a collection of your choice.
4343

4444
```java
4545
POST("/rainbow", routeContext -> {
46-
List<String> rainbowList = routeContext.getParameter("rainbow").toList(String.class);
47-
Set<String> rainbowSet = routeContext.getParameter("rainbow").toSet(String.class);
48-
TreeSet<String> rainbowTreeSet = routeContext.getParameter("rainbow").toCollection(TreeSet.class, String.class);
46+
List<String> rainbowList = routeContext.getParameter("rainbow").toList(String.class);
47+
Set<String> rainbowSet = routeContext.getParameter("rainbow").toSet(String.class);
48+
TreeSet<String> rainbowTreeSet = routeContext.getParameter("rainbow").toCollection(TreeSet.class, String.class);
4949
}
5050
```
5151

@@ -64,23 +64,23 @@ Pippo supports overriding the `POST` method used to submit a form through the us
6464

6565
```html
6666
<form>
67-
<input name="rainbow[3]" value="Gray">
68-
<input type="hidden" name="_method" value="PATCH">
67+
<input name="rainbow[3]" value="Gray">
68+
<input type="hidden" name="_method" value="PATCH">
6969
</form>
7070
```
7171

7272
Pippo will intercept the `_method` parameter specification and route the request to the `PATCH` handler that matches the URL pattern.
7373

7474
```java
7575
PATCH("/rainbow", routeContext -> {
76-
List<String> patched = routeContext.getParameter("rainbow").toList(String.class);
77-
List<String> rainbow = dao.getRainbow();
78-
for (int i = 0; i < patched.size(); i++) {
79-
if (patched.get(i) != null) {
80-
rainbow.set(i, patched.get(i));
76+
List<String> patched = routeContext.getParameter("rainbow").toList(String.class);
77+
List<String> rainbow = dao.getRainbow();
78+
for (int i = 0; i < patched.size(); i++) {
79+
if (patched.get(i) != null) {
80+
rainbow.set(i, patched.get(i));
81+
}
8182
}
82-
}
83-
dao.updateRainbow(rainbow);
83+
dao.updateRainbow(rainbow);
8484
}
8585
```
8686

@@ -92,15 +92,14 @@ Pippo supports POSTing non-form content by specifying `_content_type` and `_cont
9292

9393
```html
9494
<form>
95-
<input type="hidden" name="_content" value="['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet']">
96-
<input type="hidden" name="_content_type" value="application/json">
97-
<input type="hidden" name="_method" value="PUT">
95+
<input type="hidden" name="_content" value="['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet']">
96+
<input type="hidden" name="_content_type" value="application/json">
97+
<input type="hidden" name="_method" value="PUT">
9898
</form>
9999
```
100100

101101
```java
102102
PUT("/rainbow", routeContext -> {
103-
List<String> rainbow = routeContext.createEntityFromBody(List.class);
103+
List<String> rainbow = routeContext.createEntityFromBody(List.class);
104104
});
105-
106105
```

0 commit comments

Comments
 (0)