You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Andrew Thornton <an...@caret.cam.ac.uk> on 2005/02/03 15:19:15 UTC
HtmlDateRenderer or HtmlInputDate broken
Hi,
I'm currently trying to use the x:inputDate tag and unless I set the
type to "both" (or something other than type and date.) I find that the
parse() method of the UserData innerclass will always throw a
ParseException. Having looked at the HtmlDateRenderer source code I have
decided that this occurs because the Renderer never sets the values of
the Day Month Year -- if type is time -- or Minute Hour Second -- if the
type is date. This results in them remaining null and hence failing when
the parse occurs.
I think the correct place to fix this is in
HtmlDateRenderer.encodeEnd(), and I attach a patch which should fix it.
The only issue I can see at the moment, is if someone was to dynamically
change the type of the input it would lose the old information.
Thanks,
andy
PS Do know your mail archives for January are broken?
--
Andrew Thornton
andrew@caret.cam.ac.uk
Re: HtmlDateRenderer or HtmlInputDate broken
Posted by Andrew Thornton <an...@caret.cam.ac.uk>.
Sylvain Vieujot wrote:
> Thank you for your message.
> I guess you have this problem because your initial backing bean property
> is null.
yeah, it's just been created.
> So, I think a simpler fix is to never have userData properties null.
> I just changed the UserData constructor to set the time to now if the
> backing bean is null.
Yes that would be the better idea. d'oh. However I'm not sure that
setting it to the current time would be the correct behaviour, for
example: if I were to use SimpleDateFormat("hh mm ss").parse("19 00 00")
I would get a date representing 7pm on 1st January 1970, similarly if
you used SimpleDateFormat("dd MM YYYY").parse("01 01 2000") you get get
a date representing Midnight on 1st January 2000. Hence perhaps you
should set the date to be unix 0 time.
Thanks,
andy
--
Andrew Thornton
andrew@caret.cam.ac.uk
Re: HtmlDateRenderer or HtmlInputDate broken
Posted by Sylvain Vieujot <sv...@apache.org>.
Thank you for your message.
I guess you have this problem because your initial backing bean property
is null.
So, I think a simpler fix is to never have userData properties null.
I just changed the UserData constructor to set the time to now if the
backing bean is null.
On Thu, 2005-02-03 at 14:19 +0000, Andrew Thornton wrote:
> Hi,
>
> I'm currently trying to use the x:inputDate tag and unless I set the
> type to "both" (or something other than type and date.) I find that the
> parse() method of the UserData innerclass will always throw a
> ParseException. Having looked at the HtmlDateRenderer source code I have
> decided that this occurs because the Renderer never sets the values of
> the Day Month Year -- if type is time -- or Minute Hour Second -- if the
> type is date. This results in them remaining null and hence failing when
> the parse occurs.
>
> I think the correct place to fix this is in
> HtmlDateRenderer.encodeEnd(), and I attach a patch which should fix it.
> The only issue I can see at the moment, is if someone was to dynamically
> change the type of the input it would lose the old information.
>
> Thanks,
> andy
>
> PS Do know your mail archives for January are broken?
>
> --
> Andrew Thornton
> andrew@caret.cam.ac.uk
>
> plain text document attachment (patch)
>
> diff -r1.14 HtmlDateRenderer.java
> 268c268,272
> < }
> ---
> > } else {
> > userData.setDay("01");
> > userData.setMonth("01");
> > userData.setYear("1970");
> > }
> 274c278,282
> < }
> ---
> > } else {
> > userData.setHours("00");
> > userData.setMinutes("00");
> > userData.setSeconds("00");
> > }