private String filterNew(InvocationChain chain) throws Exception {

    Action action = chain.getAction();

    super.setInput(action.getInput());

    action.setInput(this);

    this.action.set(action);

    return chain.invoke();
  }
  /**
   * Filters the action, begining a transaction before the action's execution and commiting or
   * rollbacking the trasaction after the action's exection depending on the result.
   */
  public String filter(InvocationChain chain) throws Exception {
    Action action = chain.getAction();
    Input input = action.getInput();

    if (onlyPost) {

      // only execute for POST...

      String method = input.getProperty("method");

      boolean isPost = method != null && method.equalsIgnoreCase("post");

      if (!isPost) return chain.invoke();
    }

    Transaction transaction = (Transaction) input.getValue(transactionKey);

    // special case: two actions with transaction filter being called in a chain:
    /*
     * if (transaction != null && (transaction.wasCommited() || transaction.wasRolledBack())) {
     *
     * input.removeValue(transactionKey);
     *
     * transaction = (Transaction) input.getValue(transactionKey); }
     *
     * // by Sergio: You can now freely re-use transaction (since 1.16)
     */

    if (transaction == null) {

      Debug.log(NAME, "Transaction was NULL inside TransactionFilter!!!");

      throw new FilterException(
          "Cannot find transaction in action's " + "input with the given key: " + transactionKey);
    }

    try {

      Debug.log(NAME, "Beginning transaction...");

      transaction.begin();

      Debug.log(NAME, "Transaction was begun! Will invoke action...");

      String result = chain.invoke();

      boolean shouldRollback = resultsForRollback.contains(result);

      boolean shouldCommit = resultsForCommit.contains(result);

      if (shouldCommit || (!shouldCommit && !shouldRollback)) {

        Debug.log(NAME, "Result was ok! Will commit the transaction...", "Result=", result);

        transaction.commit();

        Debug.log(NAME, "Transaction was committed!");

      } else {

        Debug.log(NAME, "Result was not ok! Will rollback the transaction...", "Result=", result);

        transaction.rollback();

        Debug.log(NAME, "Transaction was rolled back!");
      }

      return result;

    } catch (Exception e) {

      e.printStackTrace();

      // rollbacks the transcion if any error occours.

      Debug.log(
          NAME,
          "An exception was thrown while executing action! Will try to rollback...",
          "msg=",
          e.getMessage());

      if (transaction.isActive()) {
        transaction.rollback();
        Debug.log(NAME, "Transaction was rolled back!");
      }

      throw e;
    }
  }