Package com.github.dandelion.datatables.core.callback

Examples of com.github.dandelion.datatables.core.callback.CallbackType


    AbstractTableTag parent = (AbstractTableTag) findAncestorWithClass(this, AbstractTableTag.class);

    // The tag is evaluated only once, at the first iteration
    if (parent.isFirstIteration()) {

      CallbackType callbackType = null;
      try {
        callbackType = CallbackType.valueOf(this.type.toUpperCase().trim());
      }
      catch (IllegalArgumentException e) {
        StringBuilder sb = new StringBuilder();
        sb.append("'");
        sb.append(this.type);
        sb.append("' is not a valid callback type. Possible values are: ");
        sb.append(EnumUtils.printPossibleValuesOf(CallbackType.class));
        throw new JspException(sb.toString());
      }

      function = ProcessorUtils.getValueAfterProcessingBundles(function, request);
     
      // The callback has already been registered
      if (parent.getTable().getTableConfiguration().hasCallback(callbackType)) {
        parent.getTable()
            .getTableConfiguration()
            .getCallback(callbackType)
            .appendCode(
                (callbackType.hasReturn() ? "return " : "") + function + "("
                    + StringUtils.join(callbackType.getArgs(), ",") + ");");
      }
      // The callback hasn't been registered yet
      else {
        parent.getTable()
            .getTableConfiguration()
            .registerCallback(
                new Callback(callbackType, (callbackType.hasReturn() ? "return " : "") + function + "("
                    + StringUtils.join(callbackType.getArgs(), ",") + ");"));
      }
    }

    return EVAL_PAGE;
  }
View Full Code Here


      if (hasAttribute(element, "function")) {

        String functionStr = getStringValue(element, "function");
        functionStr = ProcessorUtils.getValueAfterProcessingBundles(functionStr, request);
        CallbackType callbackType = null;
        try {
          callbackType = CallbackType.valueOf(typeStr.toUpperCase().trim());
        } catch (IllegalArgumentException e) {
          StringBuilder sb = new StringBuilder();
          sb.append("'");
          sb.append(typeStr);
          sb.append("' is not a valid callback type. Possible values are: ");
          sb.append(EnumUtils.printPossibleValuesOf(CallbackType.class));
          throw new ConfigurationProcessingException(sb.toString());
        }

        if (configs.get(tableId).containsKey(ConfType.CALLBACK)) {
          List<Callback> callbacks = (List<Callback>) configs.get(tableId).get(ConfType.CALLBACK);

          if (Callback.hasCallback(callbackType, callbacks)) {
            Callback.findByType(callbackType, callbacks).appendCode(
                (callbackType.hasReturn() ? "return " : "") + functionStr + "("
                    + StringUtils.join(callbackType.getArgs(), ",") + ");");
          } else {
            callbacks.add(new Callback(callbackType, (callbackType.hasReturn() ? "return " : "")
                + functionStr + "(" + StringUtils.join(callbackType.getArgs(), ",") + ");"));
          }
        } else {
          List<Callback> callbacks = new ArrayList<Callback>();
          callbacks.add(new Callback(callbackType, (callbackType.hasReturn() ? "return " : "") + functionStr
              + "(" + StringUtils.join(callbackType.getArgs(), ",") + ");"));

          configs.get(tableId).put(ConfType.CALLBACK, callbacks);
        }
      } else {
        throw new ConfigurationProcessingException("The attribute '" + DataTablesDialect.DIALECT_PREFIX
View Full Code Here

TOP

Related Classes of com.github.dandelion.datatables.core.callback.CallbackType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.