Example #1
0
  /** @see FacesContext#setViewRoot(javax.faces.component.UIViewRoot) */
  public void setViewRoot(UIViewRoot root) {
    assertNotReleased();
    Util.notNull("root", root);

    if (viewRoot != null && !viewRoot.equals(root)) {
      Map<String, Object> viewMap = viewRoot.getViewMap(false);
      if (viewMap != null) {
        viewRoot.getViewMap().clear();
      }
    }

    viewRoot = root;
  }
 public void processEvent(SystemEvent event) throws AbortProcessingException {
   if (event instanceof PostConstructViewMapEvent) {
     PostConstructViewMapEvent viewMapEvent = (PostConstructViewMapEvent) event;
     UIViewRoot viewRoot = (UIViewRoot) viewMapEvent.getComponent();
     viewRoot.getViewMap().put(ViewScope.VIEW_SCOPE_CALLBACKS, new HashMap<String, Runnable>());
   } else if (event instanceof PreDestroyViewMapEvent) {
     PreDestroyViewMapEvent viewMapEvent = (PreDestroyViewMapEvent) event;
     UIViewRoot viewRoot = (UIViewRoot) viewMapEvent.getComponent();
     Map<String, Runnable> callbacks =
         (Map<String, Runnable>) viewRoot.getViewMap().get(ViewScope.VIEW_SCOPE_CALLBACKS);
     if (callbacks != null) {
       for (Runnable c : callbacks.values()) {
         c.run();
       }
       callbacks.clear();
     }
   }
 }
  protected Map<String, Object> getViewMap() {
    UIViewRoot viewRoot = getViewRoot();

    if (viewRoot != null) {
      return viewRoot.getViewMap(true);
    }

    return null;
  }