Example #1
0
 /**
  * Returns the parent of the ID space, or null if not found.
  *
  * @since 5.0.0
  */
 public static IdSpace getParentIdSpace(IdSpace idspace) {
   if (idspace instanceof Component) {
     final Component c = (Component) idspace;
     final Component p = c.getParent();
     return p != null ? p.getSpaceOwner() : c.getPage();
   }
   return null;
 }
Example #2
0
  /**
   * Returns the page of the give component, or the current page if the component is null or it
   * doesn't belong to any page. The current page is retrieved by {@link
   * ExecutionCtrl#getCurrentPage} or the current execution. This method returns null if no
   * execution or no current page at all.
   *
   * @param comp the component to retrieve the page. Ignored if null.
   * @since 6.0.0
   */
  public static Page getCurrentPage(Component comp) {
    if (comp != null) {
      Page page = comp.getPage();
      if (page != null) return page;
    }

    final Execution exec = Executions.getCurrent();
    return exec != null ? ((ExecutionCtrl) exec).getCurrentPage() : null;
  }
  private void internalInvoke(final Component component, final Object target) {
    // save a reference to the page because the component can be removed
    // during the invocation of the listener and thus lose its parent
    Page page = component.getPage();

    // initialization is required for stateless pages
    if (!page.isInitialized()) {
      page.internalInitialize();
    }

    ((IRequestListener) target).onRequest();
  }
Example #4
0
 /**
  * Replaces a component with another.
  *
  * @param oldc the component to remove.
  * @param newc the component to add
  * @exception IllegalArgumentException if oldc's parent and page are both null.
  * @since 3.5.2
  */
 public static void replace(Component oldc, Component newc) {
   final Component p = oldc.getParent(), sib = oldc.getNextSibling();
   if (p != null) {
     oldc.detach();
     p.insertBefore(newc, sib);
   } else {
     final Page page = oldc.getPage();
     if (page == null) throw new IllegalArgumentException("Neither child nor attached, " + oldc);
     oldc.detach();
     if (newc.getParent() != null) newc.detach();
     newc.setPageBefore(page, sib);
   }
 }