0 Replies Latest reply on Oct 6, 2011 4:16 PM by aldosilva

    rich:select + a4j:ajax + backbutton browser

    aldosilva

      Hi everybory.

       

      I have a problem when the user click on the backbutton in the browser.

       

      I have a page with this code:

       

      <h:panelGrid>
           <rich:panel>
                <f:facet name="header">
                     <h:outputText value="Selecione o Usuário"></h:outputText>
                </f:facet>
                <rich:select value="#{selectUserAndPhase.itemUserValue}" defaultLabel="Selecione"  valueChangeListener="#                                          {selectUserAndPhase.valueChanged}" id="selectUserMenu" required="true" requiredMessage="obrigatório">
                          <f:selectItems value="#{selectUserAndPhase.listUser}" />
                          <a4j:ajax event="selectitem"  render="selectPhase" execute="@this" />
                 </rich:select>
           </rich:panel>
           <rich:message for="selectUserMenu" />
           <br />
           <a4j:outputPanel id="selectPhase" layout="block" >
                <rich:panel>
                     <f:facet name="header">
                          <h:outputText value="Selecione a Fase"></h:outputText>
                     </f:facet>
                      <rich:select value="#{selectUserAndPhase.itemPhaseValue}" defaultLabel="Selecione" id="selectPhaseMenu"                          required="true"   requiredMessage="obrigatório">
                           <f:selectItems value="#{selectUserAndPhase.listPhase}" />
                      </rich:select>
                </rich:panel>
                <rich:message for="selectPhaseMenu" />
           </a4j:outputPanel>
      </h:panelGrid>
      

       

       

      The problem occurs when the user goes to another page and return to this page through browser backbutton. The first rich:select doesn't reload

      the items and the outputPanel has already done the validation.

       

      Is there any way to reload the first rich:select when the user clicks on the backbutton?

       

      I implemented the PhaseListener but didn't solve my problem.

       

      public class NoBrowserCachePhaseListener implements PhaseListener{
      
          private static final long serialVersionUID = 1L;
      
          public void afterPhase(PhaseEvent event) {
                  // Do nothing special
          }
      
          public void beforePhase(PhaseEvent event) {
                  FacesContext facesContext = event.getFacesContext();
                  HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
                  response.addHeader("Pragma", "no-cache");
                  response.addHeader("Cache-Control", "no-cache");
                  response.addHeader("Cache-Control", "no-store");
                  response.addHeader("Cache-Control", "must-revalidate");
                  response.addHeader("Expires", "0");
          }
      
          public PhaseId getPhaseId() {
                  return PhaseId.RENDER_RESPONSE;
          } 
      }