• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

rich:calendar and locale

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using rich:calendar in my multi-lingual JSF app. Users can switch between English, French, German, Italian, and Dutch as the display language. The rich:calendar component is supposed to be locale aware, and I have the locale attribute set on it. When the locale changes in the current FacesContext, everything on the page changes to the new language and locale, including the popup calendar. But the display field portion of the rich:calendar (the text area that displays the selected date) does not. The date remains in the previous locale and then fails validation when the form is submitted. I have to manually pop up the calendar again and re-select the date in order to get it to validate. This is unacceptable because some of the date fields contain default values, and they need to change to the new locale/language along with the rest of the page.

Can anyone help with a workaround for this? How can I get the selected date to automatically change to the new selected locale without having to re-select it?

I am using RichFaces 3.3.1

JSF snippet:


Java bean snippet:
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The FacesContext is destroyed and re-created for each JSF request. You are not "storing the locale in the FacesContext".

What you need is a backing bean (e.g., localeBean) with session scope to hold that locale info. Don't use request scope because request scope beans are likewise destroyed and re-created, so the locale information will repeatedly reset. View Scope is probably not a safe option either. Plus, it's unlikely that only one View is going to be locale-sensitive.

The locale information MUST be set BEFORE the View is initially displayed. This is one reason why I like my webapps to have a public landing page. That page can gather up user information such as browser type, locale, current window size and so forth and transmit it to the server so that the actual working pages will have what they need.
 
Michael Maurer
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am already storing the locale in a session scoped backing bean.
When a different language is selected, all text on all pages in the entire app changes to the selected language. The rich:calendar component (the popup calendar) changes to the selected language. Everything appears to work as it should, except for the selected date being displayed in the text area of the rich:calendar component. It remains in the original language and fails validation when the page is submitted.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I'm getting misdirected by the use of "changes to", since it implies changes AFTER the page was displayed when you PROBABLY mean that NEW pages display with the locale set properly.

Regardless, you have a date pattern in your tag. It's almost certainly overriding the locale.
 
Michael Maurer
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I am using a date pattern. Today's date displays as "09-May-2014" in english, and "09-Mai-2014" in french.

See attached screenshots for an example.

cal1.jpg = In French language, select dates from rich:calendar component.
cal2.jpg = Switch to English language. Page displays in English, but dates are still in French and fail validation.
cal1.jpg
[Thumbnail for cal1.jpg]
French
cal2.jpg
[Thumbnail for cal2.jpg]
Switch to English, but French dates still displayed and won't validate
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic