You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Virginie Garcin <vi...@equitativa.com> on 2018/01/03 07:01:56 UTC
wicket:for inside a propertyListView doesn't generate id on the
input
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>
Re: wicket:for inside a propertyListView doesn't generate id on the
input
Posted by Virginie Garcin <vi...@equitativa.com>.
Hi Bas,
Thank you for your reply. You're right: the order here changes
everything and the id is generated if I switch the elements.
It's confusing that the behaviour of wicket:for isn't consistant
depending on html elements order, in my opinion the order shouldn't
matter.
Best regards,
Virginie
On Wed, 2018-01-03 at 00:16 -0800, Bas Gooren wrote:
> 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.garcin@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>
Re: wicket:for inside a propertyListView doesn't generate id on the input
Posted by Bas Gooren <ba...@iswd.nl>.
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.garcin@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>