How can we display by example the format to be used to input Date in DateTextField ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How can we display by example the format to be used to input Date in DateTextField ?

Charles Moulliard
I use a DateTextField to check if a user encode date according to the
Date pattern format defined.

DateTextField textfieldFromDate = new DateTextField("fromDate", "yyyyMMdd" );

Question 1 : Is it possible in the message displayed by Wicket after
the validation in the feedbackPanel to show the correct format to be
used ?

Question 2 . Can we define the format to be used (in the case of a
date) as setLenient() to verify if the date encoded is correct unlike
as the following date "20090230" ?

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can we display by example the format to be used to input Date in DateTextField ?

Pedro Santos
about question 1, yes:
http://static.ddpoker.com/javadoc/wicket/1.4-rc2/org/apache/wicket/util/convert/ConversionException.html#setResourceKey%28java.lang.String%29

On Mon, Sep 28, 2009 at 10:57 AM, Charles Moulliard <[hidden email]>wrote:

> I use a DateTextField to check if a user encode date according to the
> Date pattern format defined.
>
> DateTextField textfieldFromDate = new DateTextField("fromDate", "yyyyMMdd"
> );
>
> Question 1 : Is it possible in the message displayed by Wicket after
> the validation in the feedbackPanel to show the correct format to be
> used ?
>
> Question 2 . Can we define the format to be used (in the case of a
> date) as setLenient() to verify if the date encoded is correct unlike
> as the following date "20090230" ?
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Pedro Henrique Oliveira dos Santos
Reply | Threaded
Open this post in threaded view
|

Re: How can we display by example the format to be used to input Date in DateTextField ?

Matthias Keller
In reply to this post by Charles Moulliard
Hi Charles

About Question 1: The validation message seems to have its origin in
FormComponent#convertInput():
It will try either  "IConverter.<date class simple name>"  or  
"IConverter"  and the used pattern will be available as the variable
"format"  (or  ${format}  as used in the string resources).

About Question 2: You'll have to subclass the DateTextField and override
getConverter().

You could then just check if the returned  super.getConverter() is of
type  DateConverter and if yes, call the setLenient() method on it.

Matt

Charles Moulliard wrote:

> I use a DateTextField to check if a user encode date according to the
> Date pattern format defined.
>
> DateTextField textfieldFromDate = new DateTextField("fromDate", "yyyyMMdd" );
>
> Question 1 : Is it possible in the message displayed by Wicket after
> the validation in the feedbackPanel to show the correct format to be
> used ?
>
> Question 2 . Can we define the format to be used (in the case of a
> date) as setLenient() to verify if the date encoded is correct unlike
> as the following date "20090230" ?
>
> Regards,
>
> Charles Moulliard
>  


smime.p7s (4K) Download Attachment