You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Erik van Oosten <e....@grons.nl> on 2009/12/13 14:06:05 UTC
Request for input on new feature idea: wicket:for attribute
Hi,
In the many Wicket applications I have seen, the most frequent error is
to not correctly set the 'for' attribute of an HTML 'label' element.
Currently it is necessary to do this from code. Although a quickly
written component will make this fairly easy, the task is occurring that
often that imho better support by wicket is warranted.
I therefore propose a new wicket:for attribute that looks as follows:
<label *wicket:for="name"*>Name</label>
<input wicket:id="name" type="text"/>
The rendered markup could for example be:
<label for="name78">Name</label>
<input id="name78" name="name78" type="text" value="..."/>
Some more thoughts on the design of the wicket:for attribute:
- The value of the attribute refers to a component by component id. The
referred component must be a sibling of the same container that provides
the markup with the label element. Referring to a component outside this
container is tricky as then component ids are no longer unique.
- The wicket:for attribute will render the 'for' attribute with the
markup id of the referenced component as value.
- The method setOuputMarkupId(true) will be called on the referenced
component.
More ideas?
If I would implement such a wicket:for attribute, would it be accepted
in Wicket core?
Regards,
Erik.
--
Erik van Oosten
http://day-to-day-stuff.blogspot.com/
Re: Request for input on new feature idea: wicket:for attribute
Posted by Peter Ertl <pe...@gmx.org>.
+1 that's a pretty frequent usecase
Am 13.12.2009 um 14:17 schrieb John Krasnay:
> +1, great idea!
>
> jk
>
> On Sun, Dec 13, 2009 at 02:06:05PM +0100, Erik van Oosten wrote:
>> Hi,
>>
>> In the many Wicket applications I have seen, the most frequent error is
>> to not correctly set the 'for' attribute of an HTML 'label' element.
>> Currently it is necessary to do this from code. Although a quickly
>> written component will make this fairly easy, the task is occurring that
>> often that imho better support by wicket is warranted.
>>
>> I therefore propose a new wicket:for attribute that looks as follows:
>>
>> <label *wicket:for="name"*>Name</label>
>> <input wicket:id="name" type="text"/>
>>
>> The rendered markup could for example be:
>>
>> <label for="name78">Name</label>
>> <input id="name78" name="name78" type="text" value="..."/>
>>
>> Some more thoughts on the design of the wicket:for attribute:
>> - The value of the attribute refers to a component by component id. The
>> referred component must be a sibling of the same container that provides
>> the markup with the label element. Referring to a component outside this
>> container is tricky as then component ids are no longer unique.
>> - The wicket:for attribute will render the 'for' attribute with the
>> markup id of the referenced component as value.
>> - The method setOuputMarkupId(true) will be called on the referenced
>> component.
>>
>> More ideas?
>> If I would implement such a wicket:for attribute, would it be accepted
>> in Wicket core?
>>
>> Regards,
>> Erik.
>>
>>
>> --
>> Erik van Oosten
>> http://day-to-day-stuff.blogspot.com/
>>
>>
Re: Request for input on new feature idea: wicket:for attribute
Posted by John Krasnay <jo...@krasnay.ca>.
+1, great idea!
jk
On Sun, Dec 13, 2009 at 02:06:05PM +0100, Erik van Oosten wrote:
> Hi,
>
> In the many Wicket applications I have seen, the most frequent error is
> to not correctly set the 'for' attribute of an HTML 'label' element.
> Currently it is necessary to do this from code. Although a quickly
> written component will make this fairly easy, the task is occurring that
> often that imho better support by wicket is warranted.
>
> I therefore propose a new wicket:for attribute that looks as follows:
>
> <label *wicket:for="name"*>Name</label>
> <input wicket:id="name" type="text"/>
>
> The rendered markup could for example be:
>
> <label for="name78">Name</label>
> <input id="name78" name="name78" type="text" value="..."/>
>
> Some more thoughts on the design of the wicket:for attribute:
> - The value of the attribute refers to a component by component id. The
> referred component must be a sibling of the same container that provides
> the markup with the label element. Referring to a component outside this
> container is tricky as then component ids are no longer unique.
> - The wicket:for attribute will render the 'for' attribute with the
> markup id of the referenced component as value.
> - The method setOuputMarkupId(true) will be called on the referenced
> component.
>
> More ideas?
> If I would implement such a wicket:for attribute, would it be accepted
> in Wicket core?
>
> Regards,
> Erik.
>
>
> --
> Erik van Oosten
> http://day-to-day-stuff.blogspot.com/
>
>
Re: Request for input on new feature idea: wicket:for attribute
Posted by Erik van Oosten <e....@grons.nl>.
Nice! It must be a good idea then :)
If you go beyond a simple sibling, the referred component can be
anywhere on the page. I know of no reasonable simple way to refer such a
component (except through code). Therefor I think it is reasonable to
limit this feature to sibling components only. The route through code is
always present.
Regards,
Erik.
Jonas wrote:
> There's already a feature request in jira for this:
>
> https://issues.apache.org/jira/browse/WICKET-1469
>
> I tried implementing it once, but I run into trouble with component
> hierarchy. Only
> allowing labels for sibling components would probably make the implementation
> a lot easier, but I'm not sure if this a too big limitation to only
> allow siblings.
>
> Consider the situation when the input field and the label are in different table
> cells, e.g.
>
> <tr><td wicket:id=...><input wicket:id=... .../></td><td
> wicket:id=...><label wicket:id=... .../></td></tr>
>
> but you need to append some attributes to the td tags (e.g. for coloring).
> If I understood correctly what you suggested, this usecase wouldn't be covered.
>
> cheers,
> Jonas
>
>
--
Erik van Oosten
http://day-to-day-stuff.blogspot.com/
Re: Request for input on new feature idea: wicket:for attribute
Posted by Jonas <ba...@gmail.com>.
There's already a feature request in jira for this:
https://issues.apache.org/jira/browse/WICKET-1469
I tried implementing it once, but I run into trouble with component
hierarchy. Only
allowing labels for sibling components would probably make the implementation
a lot easier, but I'm not sure if this a too big limitation to only
allow siblings.
Consider the situation when the input field and the label are in different table
cells, e.g.
<tr><td wicket:id=...><input wicket:id=... .../></td><td
wicket:id=...><label wicket:id=... .../></td></tr>
but you need to append some attributes to the td tags (e.g. for coloring).
If I understood correctly what you suggested, this usecase wouldn't be covered.
cheers,
Jonas
On Sun, Dec 13, 2009 at 2:06 PM, Erik van Oosten <e....@grons.nl> wrote:
> Hi,
>
> In the many Wicket applications I have seen, the most frequent error is to
> not correctly set the 'for' attribute of an HTML 'label' element. Currently
> it is necessary to do this from code. Although a quickly written component
> will make this fairly easy, the task is occurring that often that imho
> better support by wicket is warranted.
>
> I therefore propose a new wicket:for attribute that looks as follows:
>
> <label *wicket:for="name"*>Name</label>
> <input wicket:id="name" type="text"/>
>
> The rendered markup could for example be:
>
> <label for="name78">Name</label>
> <input id="name78" name="name78" type="text" value="..."/>
>
> Some more thoughts on the design of the wicket:for attribute:
> - The value of the attribute refers to a component by component id. The
> referred component must be a sibling of the same container that provides the
> markup with the label element. Referring to a component outside this
> container is tricky as then component ids are no longer unique.
> - The wicket:for attribute will render the 'for' attribute with the markup
> id of the referenced component as value.
> - The method setOuputMarkupId(true) will be called on the referenced
> component.
>
> More ideas?
> If I would implement such a wicket:for attribute, would it be accepted in
> Wicket core?
>
> Regards,
> Erik.
>
>
> --
> Erik van Oosten
> http://day-to-day-stuff.blogspot.com/
>
>
>