Class LocaleChangeEvent


public class LocaleChangeEvent extends SessionEvent<LocaleChangeListener>
Session event fired when the user's locale is changed dynamically via LanguageSwitcher.

This event carries both the previous and new Locale, allowing listeners to update their content, re-render UI components, adjust text direction for RTL languages, or perform any other locale-dependent updates.

The event is dispatched to all LocaleChangeListener instances registered on the current session. Pages that need to react to language changes should implement LocaleChangeListener and register for this event.

Usage:


 // Register for locale changes (typically in createBody)
 OorianSession.get().registerListener(this, LocaleChangeEvent.class);

 // Handle the event
 public void onEvent(LocaleChangeEvent event)
 {
     Locale newLocale = event.getNewLocale();
     // Re-render content with new locale...
     sendUpdate();
 }
 
Since:
2.1
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • LocaleChangeEvent

      public LocaleChangeEvent(Locale previousLocale, Locale newLocale)
      Constructs a new LocaleChangeEvent with the previous and new locales.
      Parameters:
      previousLocale - the locale before the change
      newLocale - the locale after the change
  • Method Details

    • getPreviousLocale

      public Locale getPreviousLocale()
      Returns the locale that was active before the change.
      Returns:
      the previous locale
    • getNewLocale

      public Locale getNewLocale()
      Returns the new locale that is now active.
      Returns:
      the new locale
    • isChanged

      public boolean isChanged()
      Returns whether the locale actually changed (previous and new are different).
      Returns:
      true if the locale changed