You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Derry Cannon <d3...@gmail.com> on 2010/03/31 22:11:35 UTC

Conversion error using inputDate with a non-US browser locale

I'm having trouble using the Tomahawk inputDate for non-US locales.  If in
Firefox I set my general.useragent.locale to "en-US", all is well.  However,
if I set my locale to "en-GB", I get a conversion error from the inputDate.
Stepping through the debugger, it appears that when my locale is "en-GB" and
I submit a date of April 15, 2010, the value of the date submitted is
"4/15/2010," while the inputDate's DateTimeConverter is expecting the value
of "15/04/2010."

I've tried the following:

   - setting the inputDate's timezone to "Europe/London"
   - associating an f:convertDateTime with the inputDate, giving the
   converter the locale of "en-GB"
   - setting the locale in f:view to "en-GB"

I've also confirmed that "en-GB" is a supported locale in the
faces-config.xml.  I'm out of ideas over here, and any help would be greatly
appreciated.

Thanks much!
Derry

Re: Conversion error using inputDate with a non-US browser locale

Posted by Derry Cannon <d3...@gmail.com>.
> Can you try with convertDateTime and specify the pattern that you want to
use

No luck - the DateTimeConverter associated with the inputDate gets called
first.


> When t:inputDate is rendered, its input fields are rendered in this form:
>
>            encodeInputDay(inputDate, writer, clientId, userData, disabled,
> readonly);
>            encodeInputMonth(inputDate, writer, clientId, userData,
> currentLocale, disabled, readonly);
>            encodeInputYear(inputDate, writer, clientId, userData,
disabled,
> readonly);
>
> For that component that is fixed and the code does not check the locale
> before render them.

Yes, that's true.  However, the javascript that takes the values from those
three fields and uses them to construct the String that is eventually passed
as the inputDate's submitted value IS locale-aware.  The problem seems to be
with the the JS not properly acknowledging the locale, and therefore using
the wrong pattern to build the value string.

Can anyone who's using inputDate in Europe send me a code snippet of how
you're using it?

Thanks!
Derry

Re: Conversion error using inputDate with a non-US browser locale

Posted by Now I find myself in question <vi...@gmail.com>.
Can you try with convertDateTime and specify the pattern that you want to
use

On Thu, Apr 1, 2010 at 3:25 AM, Derry Cannon <d3...@gmail.com> wrote:

> No, I've not tried the inputCalendar.  In stepping through the debugger,
> I'm
> seeing places where facesContext.getViewRoot().getLocale() is returning the
> proper Locale, so I'm at a loss as to why the pattern is staying
> "dd.MM.yyyy" instead of "MM.dd.yyyy."
>
> Derry
>
>
>
> On Wed, Mar 31, 2010 at 4:27 PM, Leonardo Uribe <lu...@gmail.com> wrote:
>
> > Hi
> >
> > Did you tried with the property "popupDateFormat" on t:inputCalendar? The
> > default is :
> >
> > javax.text.SimpleDateFormat("dd.MM.yyyy",
> > facesContext.getViewRoot().getLocale());
> >
> > regards,
> >
> > Leonardo Uribe
> >
> > 2010/3/31 Derry Cannon <d3...@gmail.com>
> >
> > > I'm having trouble using the Tomahawk inputDate for non-US locales.  If
> > in
> > > Firefox I set my general.useragent.locale to "en-US", all is well.
> > >  However,
> > > if I set my locale to "en-GB", I get a conversion error from the
> > inputDate.
> > > Stepping through the debugger, it appears that when my locale is
> "en-GB"
> > > and
> > > I submit a date of April 15, 2010, the value of the date submitted is
> > > "4/15/2010," while the inputDate's DateTimeConverter is expecting the
> > value
> > > of "15/04/2010."
> > >
> > > I've tried the following:
> > >
> > >   - setting the inputDate's timezone to "Europe/London"
> > >   - associating an f:convertDateTime with the inputDate, giving the
> > >   converter the locale of "en-GB"
> > >   - setting the locale in f:view to "en-GB"
> > >
> > > I've also confirmed that "en-GB" is a supported locale in the
> > > faces-config.xml.  I'm out of ideas over here, and any help would be
> > > greatly
> > > appreciated.
> > >
> > > Thanks much!
> > > Derry
> > >
> >
>

Re: Conversion error using inputDate with a non-US browser locale

Posted by Leonardo Uribe <lu...@gmail.com>.
Hi

When t:inputDate is rendered, its input fields are rendered in this form:

            encodeInputDay(inputDate, writer, clientId, userData, disabled,
readonly);
            encodeInputMonth(inputDate, writer, clientId, userData,
currentLocale, disabled, readonly);
            encodeInputYear(inputDate, writer, clientId, userData, disabled,
readonly);

For that component that is fixed and the code does not check the locale
before render them.

regards,

Leonardo Uribe

2010/3/31 Derry Cannon <d3...@gmail.com>

> No, I've not tried the inputCalendar.  In stepping through the debugger,
> I'm
> seeing places where facesContext.getViewRoot().getLocale() is returning the
> proper Locale, so I'm at a loss as to why the pattern is staying
> "dd.MM.yyyy" instead of "MM.dd.yyyy."
>
> Derry
>
>
>
> On Wed, Mar 31, 2010 at 4:27 PM, Leonardo Uribe <lu...@gmail.com> wrote:
>
> > Hi
> >
> > Did you tried with the property "popupDateFormat" on t:inputCalendar? The
> > default is :
> >
> > javax.text.SimpleDateFormat("dd.MM.yyyy",
> > facesContext.getViewRoot().getLocale());
> >
> > regards,
> >
> > Leonardo Uribe
> >
> > 2010/3/31 Derry Cannon <d3...@gmail.com>
> >
> > > I'm having trouble using the Tomahawk inputDate for non-US locales.  If
> > in
> > > Firefox I set my general.useragent.locale to "en-US", all is well.
> > >  However,
> > > if I set my locale to "en-GB", I get a conversion error from the
> > inputDate.
> > > Stepping through the debugger, it appears that when my locale is
> "en-GB"
> > > and
> > > I submit a date of April 15, 2010, the value of the date submitted is
> > > "4/15/2010," while the inputDate's DateTimeConverter is expecting the
> > value
> > > of "15/04/2010."
> > >
> > > I've tried the following:
> > >
> > >   - setting the inputDate's timezone to "Europe/London"
> > >   - associating an f:convertDateTime with the inputDate, giving the
> > >   converter the locale of "en-GB"
> > >   - setting the locale in f:view to "en-GB"
> > >
> > > I've also confirmed that "en-GB" is a supported locale in the
> > > faces-config.xml.  I'm out of ideas over here, and any help would be
> > > greatly
> > > appreciated.
> > >
> > > Thanks much!
> > > Derry
> > >
> >
>

Re: Conversion error using inputDate with a non-US browser locale

Posted by Derry Cannon <d3...@gmail.com>.
No, I've not tried the inputCalendar.  In stepping through the debugger, I'm
seeing places where facesContext.getViewRoot().getLocale() is returning the
proper Locale, so I'm at a loss as to why the pattern is staying
"dd.MM.yyyy" instead of "MM.dd.yyyy."

Derry



On Wed, Mar 31, 2010 at 4:27 PM, Leonardo Uribe <lu...@gmail.com> wrote:

> Hi
>
> Did you tried with the property "popupDateFormat" on t:inputCalendar? The
> default is :
>
> javax.text.SimpleDateFormat("dd.MM.yyyy",
> facesContext.getViewRoot().getLocale());
>
> regards,
>
> Leonardo Uribe
>
> 2010/3/31 Derry Cannon <d3...@gmail.com>
>
> > I'm having trouble using the Tomahawk inputDate for non-US locales.  If
> in
> > Firefox I set my general.useragent.locale to "en-US", all is well.
> >  However,
> > if I set my locale to "en-GB", I get a conversion error from the
> inputDate.
> > Stepping through the debugger, it appears that when my locale is "en-GB"
> > and
> > I submit a date of April 15, 2010, the value of the date submitted is
> > "4/15/2010," while the inputDate's DateTimeConverter is expecting the
> value
> > of "15/04/2010."
> >
> > I've tried the following:
> >
> >   - setting the inputDate's timezone to "Europe/London"
> >   - associating an f:convertDateTime with the inputDate, giving the
> >   converter the locale of "en-GB"
> >   - setting the locale in f:view to "en-GB"
> >
> > I've also confirmed that "en-GB" is a supported locale in the
> > faces-config.xml.  I'm out of ideas over here, and any help would be
> > greatly
> > appreciated.
> >
> > Thanks much!
> > Derry
> >
>

Re: Conversion error using inputDate with a non-US browser locale

Posted by Leonardo Uribe <lu...@gmail.com>.
Hi

Did you tried with the property "popupDateFormat" on t:inputCalendar? The
default is :

javax.text.SimpleDateFormat("dd.MM.yyyy",
facesContext.getViewRoot().getLocale());

regards,

Leonardo Uribe

2010/3/31 Derry Cannon <d3...@gmail.com>

> I'm having trouble using the Tomahawk inputDate for non-US locales.  If in
> Firefox I set my general.useragent.locale to "en-US", all is well.
>  However,
> if I set my locale to "en-GB", I get a conversion error from the inputDate.
> Stepping through the debugger, it appears that when my locale is "en-GB"
> and
> I submit a date of April 15, 2010, the value of the date submitted is
> "4/15/2010," while the inputDate's DateTimeConverter is expecting the value
> of "15/04/2010."
>
> I've tried the following:
>
>   - setting the inputDate's timezone to "Europe/London"
>   - associating an f:convertDateTime with the inputDate, giving the
>   converter the locale of "en-GB"
>   - setting the locale in f:view to "en-GB"
>
> I've also confirmed that "en-GB" is a supported locale in the
> faces-config.xml.  I'm out of ideas over here, and any help would be
> greatly
> appreciated.
>
> Thanks much!
> Derry
>