bgooren opened a new issue, #1632:
URL: https://github.com/apache/wicket/issues/1632
### Description
Using `<label wicket:for="categories">` with a standard `CheckGroup` causes
Wicket to log:
```text
Markup id set on a component that renders its body only.
```
`CheckGroup` renders its body only by default. `AutoLabelResolver`
nevertheless enables `outputMarkupId` on it, causing Wicket to warn about a
configuration introduced by its own built-in resolver.
The form renders and functions normally with the default warning strategy,
but these warnings unnecessarily pollute application logs.
### Affected version
Reproduced with Wicket 10.11.0.
### Reproduction
Java:
```java
var form = new Form<Void>("form");
form.add(new CheckGroup<String>(
"categories", Model.ofList(new ArrayList<>())));
add(form);
```
Markup:
```html
<form wicket:id="form">
<label wicket:for="categories">Categories</label>
<wicket:container wicket:id="categories"></wicket:container>
</form>
```
No custom components or resolvers are involved.
### Expected behavior
Using an auto label with a standard `CheckGroup` should not produce a
warning about an invalid markup ID configuration.
For body-only targets, the label could omit the HTML `for` attribute while
preserving label text and required/error/disabled CSS classes.
### Cause
`AutoLabelResolver.resolve()` calls `setOutputMarkupId(true)` without
checking `getRenderBodyOnly()`. `AutoLabel` also writes a `for` attribute
referencing an ID that is not present in the rendered markup.
### Verification
A minimal `WicketTester` test reproduces the problem with the default
resolvers. It verifies that `CheckGroup` starts with `renderBodyOnly=true` and
`outputMarkupId=false`, then that rendering enables `outputMarkupId` and
reaches the body-only markup ID error condition.
The test uses `NotRenderableErrorStrategy.THROW_EXCEPTION` to make that
warning condition testable as an exception. The application log warnings are
the primary issue; throwing is only used for verification.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]