Hi,

You can use wicket:for attribute:
<label wicket:for="input" wicket:id="inputLabel"><span
wicket:id="inputSpan">[label text]</span>
        <input wicket:id="input" type="text" size="50" /></label>



On Wed, Mar 6, 2013 at 5:10 PM, Lucio Crusca <lu...@sulweb.org> wrote:

> I've created three subclasses of FormComponentPanel, e.g.
> TextFormComponentPanel, CheckBoxFormComponentPanel and
> DropDownChoiceFormComponentPanel. They all share some markup logic in that
> they all have an enclosing <label> and a <span> for the text to use as
> label.
> However each class has its own markup file, because each one needs a
> different
> <input type="..."> or <select> instead. Here is for example
> TextFormComponentPanel  markup:
>
>     <wicket:panel>
>       <label for="input" wicket:id="inputLabel"><span
> wicket:id="inputSpan">[label text]</span>
>         <input wicket:id="input" id="input" type="text" size="50"
> /></label>
>     </wicket:panel>
>
>
> Then I created a FormComponentPanel derived class that uses a
> RepeatingView, and expects its derived classes to fill in the RepeatingView
> with instances of the three classes above. Those derived classes are the
> detail forms corresponding to my domain model beans.
>
> The problem is that TextFormComponentPanel, CheckBoxFormComponentPanel and
> DropDownChoiceFormComponentPanel html markup have fixed IDs for the input
> tags
> (I mean html id attributes, the ones referenced by <label for="input").
> That's
> the recipe for a mess, because I end up with multiple html elements that
> have
> the same html id.
>
> I googled around and found AutoLabelResolver and AutoLabelTextResolver. I
> suspect those classes could help me, because they generate dynamic html
> IDs,
> but I failed to find an example that shows me how to use them. While it's
> clear
> to me how the markup should look, I can't get the java side.
>
> Any help?
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to