Skip to content

Commit

Permalink
Work around code example callout bug
Browse files Browse the repository at this point in the history
This commit adds callouts to two sets of Java/Kotlin code examples in
the @ModelAttribute section for Web MVC in order to work around the
"Code example has callout from a different code example" bug.

This also aligns the Web MVC examples with the WebFlux examples.

As a side note, the bug can also be seen in the WebFlux documentation
if the callouts are removed from the first Java/Kotlin examples in the
@ModelAttribute section for WebFlux. Thus it appears to be a general
issue related to examples within a given section of the documentation
when some examples have callouts and others do not, likely due to a bug
in the Javascript that provides this feature.

See gh-29505
  • Loading branch information
sbrannen committed Nov 17, 2022
1 parent f6eaa8e commit ac7d428
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions framework-docs/src/docs/asciidoc/web/webmvc.adoc
Expand Up @@ -2662,19 +2662,21 @@ query parameters and form fields. The following example shows how to do so:
.Java
----
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
public String processSubmit(@ModelAttribute Pet pet) {
public String processSubmit(@ModelAttribute Pet pet) { // <1>
// method logic...
}
----
<1> Bind an instance of `Pet`.

[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
fun processSubmit(@ModelAttribute pet: Pet): String {
fun processSubmit(@ModelAttribute pet: Pet): String { // <1>
// method logic...
}
----
<1> Bind an instance of `Pet`.

The `Pet` instance above is sourced in one of the following ways:

Expand Down Expand Up @@ -2702,18 +2704,21 @@ could load the `Account` from a data store:
.Java
----
@PutMapping("/accounts/{account}")
public String save(@ModelAttribute("account") Account account) {
public String save(@ModelAttribute("account") Account account) { // <1>
// ...
}
----
<1> Bind an instance of `Pet` using an explicit attribute name.

[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@PutMapping("/accounts/{account}")
fun save(@ModelAttribute("account") account: Account): String {
fun save(@ModelAttribute("account") account: Account): String { // <1>
// ...
}
----
<1> Bind an instance of `Pet` using an explicit attribute name.

After the model attribute instance is obtained, data binding is applied. The
`WebDataBinder` class matches Servlet request parameter names (query parameters and form
Expand Down

0 comments on commit ac7d428

Please sign in to comment.