you can override newDateTextField(..) and call .setLabel() directly on the
DateTextField in there.

  Gerolf

On Wed, Mar 12, 2008 at 10:26 PM, Phil Grimm <[EMAIL PROTECTED]> wrote:

> Hey Guys,
> I'm building my first Wicket app and, so far, am really loving Wicket!
>
> I've built my first form and am stumped on a issue with the DateTime
> component. I call setLabel() on all the fields in my form and all the
> labels
> I provide appear in the validation error messages except one, the DateTime
> field.
>
> Here's the code....
>
> HTML:
>    <tr>
>          <td>My Date:</td>
>          <td><span wicket:id="myDate"></span></td>
>    </tr>
>
> JAVA:
>    form.add(new DateField("myDate").setLabel(new Model("My Date"));
>
> The problem is that the validation error message refers to the field as
> "date" and not "My Date".
>
> Looking at the source, DateTime.java, I can see why. It appears the
> setLabel() is being applied to the FormComponentPanel, which DateTime
> extends and not the 'private final DateTextField dateField' within
> DateTime.
>
> I don't see a way to get at the private "dateField" to setLabel() on it.
> How should this be done?
>
>
> And a related setLabel() question....
>
> Looking at my example code above, you can see that the label "My Date" is
> being maintained in both the HTML and the Java. It would be nice if I
> could
> just specify it in the Java and have Wicket apply it in the HTML.
>
> For example...
>
> HTML:
>    <tr>
>          <td><span wicket:id="myDate.label">[wicket puts label here - with
> colon?]</span></td>
>          <td><span wicket:id="myDate"></span></td>
>    </tr>
>
> Is this possible now?
> Or is it a reasonable feature idea?
>
>
> Thanks!
> Phil
>

Reply via email to