Пример #1
0
 /**
  * finds the component with the given id that is located in the same NamingContainer as a given
  * component
  *
  * @param fc the FacesContext
  * @param componentId the component id
  * @param nearComponent a component within the same naming container from which to start the
  *     search (optional)
  * @return the component or null if no component was found
  */
 public UIComponent findComponent(FacesContext fc, String componentId, UIComponent nearComponent) {
   if (StringUtils.isEmpty(componentId))
     throw new InvalidArgumentException("componentId", componentId);
   // Begin search near given component (if any)
   UIComponent component = null;
   if (nearComponent != null) { // Search below the nearest naming container
     component = nearComponent.findComponent(componentId);
     if (component == null) { // Recurse upwards
       UIComponent nextParent = nearComponent;
       while (true) {
         nextParent = nextParent.getParent();
         // search NamingContainers only
         while (nextParent != null && !(nextParent instanceof NamingContainer)) {
           nextParent = nextParent.getParent();
         }
         if (nextParent == null) {
           break;
         } else {
           component = nextParent.findComponent(componentId);
         }
         if (component != null) {
           break;
         }
       }
     }
   }
   // Not found. Search the entire tree
   if (component == null) component = findChildComponent(fc.getViewRoot(), componentId);
   // done
   return component;
 }
Пример #2
0
 public static String decodeActionParam(String param) {
   ParameterMap pm = FacesUtils.getParameterMap(FacesUtils.getContext());
   if (pm == null) return param;
   String action = StringUtils.toString(pm.get(ACTION_PARAMETER_TYPE, param));
   if (action == null) log.warn("no action available for param {}.", param);
   return action;
 }
Пример #3
0
  /**
   * Creates an Oracle specific select statement that supports special features of the Oracle DBMS
   * like e.g. CONNECT BY PRIOR
   *
   * @param buf the SQL statement
   */
  @Override
  public synchronized void getSelect(StringBuilder buf) {
    List<DBAliasExpr> aliases = new ArrayList<DBAliasExpr>();
    resetParamUsage();
    if (select == null) throw new ObjectNotValidException(this);

    // Prepares statement
    if ((limitRows != null) || (skipRows != null)) {
      // add aliases
      Iterator<DBColumnExpr> iter = select.iterator();
      int i = 0;
      while (iter.hasNext()) {
        i++;
        aliases.add(new DBAliasExpr(iter.next(), "alias" + i));
      }

      buf.append("SELECT * FROM (\r\n");
    }

    buf.append("SELECT ");
    if (StringUtils.isNotEmpty(optimizerHint)) { // Append an optimizer hint
      // to the select
      // statement e.g. SELECT
      // /*+ RULE */
      buf.append("/*+ ").append(optimizerHint).append(" */ ");
    }
    if (selectDistinct) buf.append("DISTINCT ");

    // Add Select Expressions
    if ((limitRows != null) || (skipRows != null)) {
      addListExpr(buf, aliases, CTX_ALL, ", ");
      buf.append(", row_number() over (");
      insertOrderBy(buf);
      buf.append(") as rownumber ");
    } else {
      addListExpr(buf, select, CTX_ALL, ", ");
    }

    addFrom(buf);
    // Where

    addWhere(buf);
    // Connect By
    if (connectBy != null) { // Add 'Connect By Prior' Expression
      buf.append("\r\nCONNECT BY PRIOR ");
      connectBy.addSQL(buf, CTX_DEFAULT | CTX_NOPARENTHESES);
      // Start With
      if (startWith != null) { // Add 'Start With' Expression
        buf.append("\r\nSTART WITH ");
        startWith.addSQL(buf, CTX_DEFAULT);
      }
    }
    // Grouping
    addGrouping(buf);
    // Order
    if ((skipRows == null) && (limitRows == null)) {
      insertOrderBy(buf);
    } else {
      buf.append(") WHERE (");
      if (skipRows != null) {
        buf.append("rownumber>" + skipRows.toString());
      }

      if (limitRows != null) {
        if (skipRows != null) {
          buf.append(" AND ");
        }
        Integer outputLimit = new Integer(limitRows.intValue());
        if (skipRows != null) {
          outputLimit += skipRows;
        }

        buf.append("rownumber<=" + outputLimit.toString());
      }
      buf.append("\r\n)");
    }
  }
Пример #4
0
 public PageOutcome getRedirectWithViewParams(String action) {
   PageOutcome outcome = getRedirectWithViewParams();
   if (StringUtils.isNotEmpty(action))
     outcome = outcome.addParam("action", encodeActionParam(action));
   return outcome;
 }
Пример #5
0
 public PageOutcome getOutcome(String action) {
   PageOutcome outcome = getOutcome();
   if (StringUtils.isNotEmpty(action))
     outcome = outcome.addParam("action", encodeActionParam(action));
   return outcome;
 }