Hi Virginie,

Looking through the wicket source code, I see that wicket:for is handled
through a component resolver (see AutoLabelResolver).

Since these are run at render time (see MarkupContainer#renderNext()) and
your label is after the checkbox in html, it means that your checkbox input
is already rendered when the AutoLabelResolver runs.


To fix this, please call setOutputMarkupId(true) yourself on the checkbox,
or put the label before the checkbox in your html.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 3 januari 2018 bij 08:02:15, Virginie Garcin (
virginie.gar...@equitativa.com) schreef:

Hi there,

When we are using wicket:for into a PropertyListView, the id is not
automatically set on the related input, except if we force it by using
setOutputMarkupId(true).
Outside a propertyListView the id is generated without forcing it.
Please can you tell me if it's normal, if I use it incorrectly or if it is
a bug?
We are using Wicket 8.0.0-M8.

Thanks and regards,
Virginie

HTML:
<tr wicket:id="variations">
<td>
<div class="custom-control custom-checkbox">
<input wicket:id="active" type="checkbox" class="custom-control-input"/>
<label wicket:for="active" class="custom-control-label">Active</label>
</div>
</td>
</tr>

Java:
form.add( new PropertyListView<ProductVariation>( "variations" ) {
@Override
protected void populateItem(final ListItem<ProductVariation> variationItem)
{
variationItem.add( new CheckBox( "active" ) );
}
} );

Output HTML: the "for" on the label is there but the "id" on the input is
missing.
<tr>
<td class="align-middle">
<div class="custom-control custom-checkbox">
<input class="custom-control-input beingEdited pristine" checked="checked"
name="variations:0:active" type="checkbox">
<label class="custom-control-label" id="activebb-w-lbl"
for="activebb">Active</label>
</div>
</td>
</tr>

Reply via email to