title: How to keep JSF flash scope parameters on page reload?
body: <p>I use flash scope to pass a setting object between @viewscoped contollers. But if I make a page reload on one of them, then the flash map is empty and the setting object is not initialized. Is it possible to keep flash scope on page reload?</p>
  
  <p>My source code to store/retrieve settings:</p>
  
  <p>FistPage.xhtml</p>
  
  <pre><code>...
  &lt;p:commandButton value="next"
      action="#{firstPageController.transferConfig}"  
      process="@this" /&gt;
  ...
  </code></pre>
  
  <p>FirstPageController.java</p>
  
  <pre><code>@ManagedBean(name = "firstPageController")
  @ViewScoped
  public class FirstPageController {
  ...
  public String transferConfig() {
  FacesContext.getCurrentInstance().getExternalContext().getFlash().put("searchConfig",   searchConfig);
  return "/secondPage.xhtml?faces-redirect=true";
  }
  ...
  }
  </code></pre>
  
  <p>SecondPage.xhtml</p>
  
  <pre><code>...
  &lt;h:outputLabel value="value"&gt;
      &lt;f:event type="preRenderComponent" listener="#{secondPageController.onPageLoad()}"/&gt;
  &lt;/h:outputLabel&gt;
  ...
  </code></pre>
  
  <p>SecondPageController.java</p>
  
  <pre><code>@ManagedBean(name = "secondPageController")
  @ViewScoped
  public class SecondPageController {
      ...
      public void onPageLoad() 
      {
          flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();
  
          searchConfig = ((SearchFilterConfig) flash.get("searchConfig"));
  
          flash.putNow("searchConfig", searchConfig);
  
          flash.keep("searchConfig");
      }
      ...
  }
  </code></pre>
  
  <p>I use Mojarra 2.1.29</p>
  
  <p>Thanks</p>