You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by "bgooren (via GitHub)" <gi...@apache.org> on 2026/10/01 09:38:32 UTC
[I] AutoLabelResolver causes unnecessary markup ID warnings for CheckGroup [wicket]
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: dev-unsubscribe@wicket.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AutoLabelResolver causes unnecessary markup ID warnings for CheckGroup [wicket]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on issue #1632:
URL: https://github.com/apache/wicket/issues/1632#issuecomment-5929771441
For me the problem is that this hides the issue for other users who applied the AutoLabel to a body-only rendering component by mistake.
--
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: dev-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AutoLabelResolver causes unnecessary markup ID warnings for CheckGroup [wicket]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on issue #1632:
URL: https://github.com/apache/wicket/issues/1632#issuecomment-5929475067
IMO the warning log is the correct thing to do here. The log message tells you that you are doing something that won't work as you'd expect.
Since `for='...'` won't be produced and you are OK with this then you actually need to use `wicket:id=...` instead of `wicket:for=...`. This way you will have a plain Label, i.e. just a text that won't focus the input field when clicked.
--
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: dev-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AutoLabelResolver causes unnecessary markup ID warnings for CheckGroup [wicket]
Posted by "bgooren (via GitHub)" <gi...@apache.org>.
bgooren closed issue #1632: AutoLabelResolver causes unnecessary markup ID warnings for CheckGroup
URL: https://github.com/apache/wicket/issues/1632
--
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: dev-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AutoLabelResolver causes unnecessary markup ID warnings for CheckGroup [wicket]
Posted by "bgooren (via GitHub)" <gi...@apache.org>.
bgooren commented on issue #1632:
URL: https://github.com/apache/wicket/issues/1632#issuecomment-5929715205
I understand that an HTML `for` attribute cannot meaningfully target a body-only component such as `CheckGroup`.
My use case is a reusable form-field wrapper that renders a label, help text, and layout markup around an arbitrary `FormComponent`. Its markup uses `wicket:for`, so it benefits from automatic label text and required/error/disabled classes.
Since `CheckGroup` is itself a standard `FormComponent`, passing one to that wrapper currently produces warnings. The wrapper cannot decide in its static markup whether the supplied component renders its own tag.
Using `wicket:id` instead means managing the label in Java and reproducing the conditional association and form-state behavior in application code.
The proposed fix moves that decision into Wicket: retain the HTML `for` association where supported, and omit it for body-only targets while preserving the other auto-label functionality. It does not attempt to make clicking a group label focus an input.
Would supporting this reusable-component use case make sense?
--
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: dev-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AutoLabelResolver causes unnecessary markup ID warnings for CheckGroup [wicket]
Posted by "bgooren (via GitHub)" <gi...@apache.org>.
bgooren commented on issue #1632:
URL: https://github.com/apache/wicket/issues/1632#issuecomment-5930230981
I agree with your point: the warning is appropriate when an auto label is applied to a body-only component unintentionally, and we should not suppress it for everyone.
We have been seeing these warnings in our application logs for years because our reusable form-field wrappers intentionally support components such as `CheckGroup`. This proposal was one possible way to address that use case.
I have withdrawn the PR. We will implement a custom `wicket:for` resolver for our applications, preserving Wicket’s default warning behavior for other users.
Thanks for the feedback!
--
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: dev-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org