This discussion is archived
3 Replies Latest reply: Jan 9, 2013 3:45 AM by gimbal2 RSS

How to fire proper methods after language selection

795628 Newbie
Currently Being Moderated
I am developing a web application with JSF (& PrimeFaces).

It has the typical combo for language selection.

When someone hits the combo, a valueChangeListener is fired.

That listener (*changeLocaleListener*) changes the viewPort Locale, so the proper message bundle .properties file could be loaded.

This works OK as expected, BUT, I am confused about the strategy to adopt in order to load again from database the actual contents of the page that depends on i18n.

I mean, how do yo do to refresh the page calling the proper action/actionListeners methods.

Imagine the following scenario:

1. You arrive the home page (Spanish is selected as default language).

2. A list of latest news and latest events are displayed (in Spanish).

3. You click in one of the news and arrive to the detailed new page (in Spanish).

4. Yo select the English language in the combo, and then, the detailed info of the selected new SHOULD BE RELOADED from database and displayed in English.

Is there a way to automatize that and control what methods should be invoked according with the actual page the user is in?

<p:selectOneMenu
value="#{i18nCtrl.mdl.local}"
var="loc"
onchange="$('#form').submit()"
converter="localConverter"
valueChangeListener="#{i18nCtrl.changeLocaleListener}" >
...

Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points