You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Phil Grimm <ph...@gmail.com> on 2008/03/12 22:26:00 UTC

DateTime.setLabel() issue and a related (but general) setLabel() question

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

Re: DateTime.setLabel() issue and a related (but general) setLabel() question

Posted by phil59 <ph...@gmail.com>.
Igor,
That's what I was thinking to suggest too, but I think that solution breaks
down when the component has more than one internal field like DateTimeField
does.

Gerolf,
Thanks for the tip. I think that should work for the dateField.
Any ideas on what would one do to set the label on the
DateTimeField.hoursField and DateTimeField.minutesField?

--Phil


igor.vaynberg wrote:
> 
> shouldnt DateField forward its label to the internal field?
> 
> -igor
> 
> 
> On Wed, Mar 12, 2008 at 2:32 PM, Gerolf Seitz <ge...@gmail.com>
> wrote:
>> you can override newDateTextField(..) and call .setLabel() directly on
>> the
>>  DateTextField in there.
>>
>>   Gerolf
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/DateTime.setLabel%28%29-issue-and-a-related-%28but-general%29-setLabel%28%29-question-tp16015278p16019096.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: DateTime.setLabel() issue and a related (but general) setLabel() question

Posted by Igor Vaynberg <ig...@gmail.com>.
shouldnt DateField forward its label to the internal field?

-igor


On Wed, Mar 12, 2008 at 2:32 PM, Gerolf Seitz <ge...@gmail.com> wrote:
> 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 <ph...@gmail.com> 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
>  >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: DateTime.setLabel() issue and a related (but general) setLabel() question

Posted by Gerolf Seitz <ge...@gmail.com>.
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 <ph...@gmail.com> 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
>