コード例 #1
0
ファイル: StateContext.java プロジェクト: ivartanian/mojarra
  /**
   * Installs a <code>SystemEventListener</code> on the <code>UIViewRoot</code> to track components
   * added to or removed from the view.
   */
  public void startTrackViewModifications(FacesContext ctx, UIViewRoot root) {

    if (modListener == null) {
      modListener = new AddRemoveListener(ctx);
      root.subscribeToViewEvent(PostAddToViewEvent.class, modListener);
      root.subscribeToViewEvent(PreRemoveFromViewEvent.class, modListener);
    }
    setTrackViewModifications(true);
  }
コード例 #2
0
  /** Constructor. */
  public DynamicParentComponent() {
    setRendererType("com.sun.faces.test.agnostic.statesaving.basic.DynamicParentComponentRenderer");

    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot root = context.getViewRoot();

    if (!context.isPostback()) {
      root.subscribeToViewEvent(PreRenderViewEvent.class, this);
    }
  }
コード例 #3
0
ファイル: ViewScope.java プロジェクト: delema/Gateway
  /**
   * Register callback to be executed only on whole scope destroying (not single object).
   *
   * @see Scope for more details
   */
  @Override
  public void registerDestructionCallback(String name, Runnable callback) {
    // logger.trace("registerDestructionCallback for bean " + name);

    UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
    ViewScopeViewMapListener listener =
        new ViewScopeViewMapListener(viewRoot, name, callback, this);

    viewRoot.subscribeToViewEvent(PreDestroyViewMapEvent.class, listener);

    HttpSession httpSession =
        (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);

    final Set<ViewScopeViewMapListener> sessionListeners;

    if (sessionToListeners.containsKey(httpSession)) {
      sessionListeners = sessionToListeners.get(httpSession);
    } else {
      synchronized (sessionToListeners) {
        if (sessionToListeners.containsKey(httpSession)) {
          sessionListeners = sessionToListeners.get(httpSession);
        } else {
          sessionListeners = new HashSet<>();
          sessionToListeners.put(httpSession, sessionListeners);
        }
      }
    }

    synchronized (sessionListeners) {
      sessionListeners.add(listener);
    }

    if (!FacesContext.getCurrentInstance()
        .getExternalContext()
        .getSessionMap()
        .containsKey("sessionBindingListener")) {
      FacesContext.getCurrentInstance()
          .getExternalContext()
          .getSessionMap()
          .put("sessionBindingListener", this);
    }
  }
コード例 #4
0
 //
 // Constructor: Subscribes to PreRenderView Event(s)
 //
 public TableComponent() {
   setRendererType("component");
   FacesContext context = FacesContext.getCurrentInstance();
   UIViewRoot root = context.getViewRoot();
   root.subscribeToViewEvent(PreRenderViewEvent.class, this);
 }