0 Replies Latest reply on Jul 17, 2008 1:26 AM by Mark Beavis

    Modal Panel and Value Change Events

    Mark Beavis Newbie

      Hi all -

      I've included a modal panel in my page to alert the user of any input errors, and it works great:

      <rich:modalPanel id="errorPanel" rendered="#{recoverPassword.hasError}" showWhenRendered="true" width="300" height="100">
      <f:facet name="header">
       <h:outputText value="Validation Error" />
      <f:facet name="controls">
       <h:graphicImage value="skins/default/img/close.png" style="cursor:pointer" onclick="Richfaces.hideModalPanel('errorPanel')" />
      <rich:messages globalOnly="true" styleClass="globalError" layout="table" /><br />
       <h:commandButton action="#" value="Close" onclick="Richfaces.hideModalPanel('errorPanel')" />

      However, I also have a select box on my page that holds several different languages. When a user changes the value of this select box, the page is rendered in the chosen language:

      <h:form id="langSwitchForm">
       <td id="langSwitch" class="banner">
       <h:outputLabel for="languageSwitch" value="#{sessionBean.labelData.langSwitch}" />
       <h:selectOneMenu id="languageSwitch" styleClass="select" onchange="submit()" value="#{sessionBean.language}" valueChangeListener="#sessionBean.changeLanguage}">
       <f:selectItems value="#sessionBean.languages}"/>

      This is implemented through a session scoped managed bean, that holds the current locale. ie:

      public void changeLanguage(ValueChangeEvent event) {
       this.locale = new Locale(event.getNewValue());

      Then, the page (request scoped) managed bean is constructed, and the page text is pulled from the database using the locale stored in the session.

      But.... when I include the <rich:modal> component in the page, the flow of actions is changed. The request scoped bean is recreated BEFORE the change value method is called. This causes the page to display the text in the wrong (old) language.

      Is this a problem anyone has come across before - or am I using the component incorrectly.

      Any light that anyone could shed on this situation would be greatly appreciated.

      Thanks -