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

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


      // 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


    assertThat(mainConf.get(DTConstants.DT_S_SERVERMETHOD)).isEqualTo("GET");
  }

  @Test
  public void should_set_a_callback() {
    Callback callback = new Callback(CallbackType.CREATEDROW, "aJavascriptFunction");
    List<Callback> callbacks = new ArrayList<Callback>();
    callbacks.add(callback);
    table.getTableConfiguration().setCallbacks(callbacks);

    Map<String, Object> mainConf = generator.generateConfig(table);

    assertThat(mainConf).hasSize(2);
    assertThat(mainConf.get(CallbackType.CREATEDROW.getName())).isEqualTo(new JavascriptFunction(callback.getFunction().getCode(), CallbackType.CREATEDROW.getArgs()));
  }
View Full Code Here

  }

  @Test
  public void should_set_several_callbacks() {
    List<Callback> callbacks = new ArrayList<Callback>();
    Callback callback = new Callback(CallbackType.CREATEDROW, "aJavascriptFunction");
    callbacks.add(callback);
    Callback callback2 = new Callback(CallbackType.COOKIE, "anotherJavascriptFunction");
    callbacks.add(callback2);
    Callback callback3 = new Callback(CallbackType.PREDRAW, "aThirdJavascriptFunction");
    callbacks.add(callback3);
    table.getTableConfiguration().setCallbacks(callbacks);

    Map<String, Object> mainConf = generator.generateConfig(table);

    assertThat(mainConf).hasSize(4);
    assertThat(mainConf.get(CallbackType.CREATEDROW.getName())).isEqualTo(new JavascriptFunction(callback.getFunction().getCode(), CallbackType.CREATEDROW.getArgs()));
    assertThat(mainConf.get(CallbackType.COOKIE.getName())).isEqualTo(new JavascriptFunction(callback2.getFunction().getCode(), CallbackType.COOKIE.getArgs()));
    assertThat(mainConf.get(CallbackType.PREDRAW.getName())).isEqualTo(new JavascriptFunction(callback3.getFunction().getCode(), CallbackType.PREDRAW.getArgs()));
  }
View Full Code Here

          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 {
View Full Code Here

TOP

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

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.