public static UIComponent findPersistent(
      FacesContext context, ServletRequest req, UIComponent parent, String id) throws Exception {
    if (context == null) context = FacesContext.getCurrentInstance();

    BodyContent body = null;

    if (parent == null) {
      UIComponentClassicTagBase parentTag =
          (UIComponentClassicTagBase) req.getAttribute("caucho.jsf.parent");

      parent = parentTag.getComponentInstance();

      body = parentTag.getBodyContent();
    }

    if (parent != null) {
      List<UIComponent> children = parent.getChildren();
      int size = children.size();

      String prevId = null;
      for (int i = 0; i < size; i++) {
        UIComponent child = children.get(i);

        if (id.equals(child.getId())) {
          if (body != null) addVerbatim(parent, prevId, body);

          return child;
        }

        if (child.getId() != null) prevId = child.getId();
      }
    }

    return null;
  }
Beispiel #2
0
  public int doStartTag() throws JspException {

    OrderEntryMgr orderEntryMgr =
        (OrderEntryMgr) this.pageContext.getSession().getAttribute("oeMgr");
    ExpectOrder expectOrder = orderEntryMgr.getCurrentExpectOrder();
    ExpectOrderMeta expectOrderMeta = orderEntryMgr.getExpectOrderMeta();

    if (expectOrderMeta == null) return Tag.SKIP_BODY;
    List salesRepList = expectOrderMeta.getSalesRepList();
    currentSalesRep = expectOrder.getSalesRep();
    if (salesRepList == null || salesRepList.size() == 0) return Tag.SKIP_BODY;
    iterator = salesRepList.iterator();

    return IterationTag.EVAL_BODY_AGAIN;
  }
Beispiel #3
0
  public int doStartTag() throws JspException {
    try {
      List headChargeList =
          ((ProcessHandleTag) getParent()).getCurrentProcessHandleFor().getHeadChargeList();

      iterator = headChargeList.iterator();

      if (headChargeList.size() == 0) {
        return SKIP_BODY;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return IterationTag.EVAL_BODY_AGAIN;
  }
  private static void addChild(UIComponent parent, String prevId, UIComponent child) {
    if (parent != null) {
      List<UIComponent> children = parent.getChildren();
      int size = children.size();
      boolean hasPrev = prevId == null;

      int i = 0;
      for (; i < size; i++) {
        UIComponent oldChild = children.get(i);

        if (hasPrev && oldChild.getId() != null) {
          children.add(i, child);

          return;
        } else if (prevId != null && prevId.equals(oldChild.getId())) hasPrev = true;
      }

      parent.getChildren().add(child);
    }
  }