@Override
  protected void prepareForm(final ActionContext context) throws Exception {
    final Transfer transfer = resolveTransfer(context);

    // Check for transaction password
    final HttpServletRequest request = context.getRequest();
    final boolean requestTransactionPassword = shouldValidateTransactionPassword(context, transfer);
    if (requestTransactionPassword) {
      context.validateTransactionPassword();
    }
    request.setAttribute("requestTransactionPassword", requestTransactionPassword);
    request.setAttribute(
        "wouldRequireAuthorization", paymentService.wouldRequireAuthorization(transfer));

    // Transfer number and number of transfers
    final int transferNumber = getTransferNumber(transfer);
    final int numberOfTransfers = getNumberOfTransfer(transfer);
    request.setAttribute("transferNumber", transferNumber);
    request.setAttribute("numberOfTransfers", numberOfTransfers);

    // Fetch related data
    final AccountOwner from = transfer.getFromOwner();
    final AccountOwner to = transfer.getToOwner();
    final TransferType transferType =
        transferTypeService.load(
            transfer.getType().getId(),
            RelationshipHelper.nested(
                TransferType.Relationships.FROM, AccountType.Relationships.CURRENCY),
            TransferType.Relationships.TO);
    final BigDecimal amount = transfer.getAmount();
    if (from instanceof Member) {
      request.setAttribute("fromMember", from);
    }
    if (to instanceof Member) {
      request.setAttribute("toMember", to);
    }
    transfer.setType(transferType);
    request.setAttribute("unitsPattern", transferType.getFrom().getCurrency().getPattern());

    // Store the transaction fees
    final TransactionFeePreviewDTO preview =
        transactionFeeService.preview(from, to, transferType, amount);
    request.setAttribute("finalAmount", preview.getFinalAmount());
    request.setAttribute("fees", preview.getFees());
    request.setAttribute("transfer", transfer);
  }
  @SuppressWarnings("unchecked")
  @Override
  protected void prepareForm(final ActionContext context) throws Exception {
    final HttpServletRequest request = context.getRequest();

    if (!context.isBroker()) {
      throw new ValidationException();
    }

    final Member broker = (Member) context.getElement();
    final BrokerGroup brokerGroup = (BrokerGroup) broker.getGroup();

    // Get broker commission transaction fees (from member) related to the broker group, including
    // the not enabled ones
    final TransactionFeeQuery transactionFeeQuery = new TransactionFeeQuery();
    transactionFeeQuery.setEntityType(BrokerCommission.class);
    transactionFeeQuery.setGeneratedTransferTypeFromNature(AccountType.Nature.MEMBER);
    transactionFeeQuery.setBrokerGroup(brokerGroup);
    transactionFeeQuery.setReturnDisabled(true);
    final List<BrokerCommission> groupCommissions =
        (List<BrokerCommission>) transactionFeeService.search(transactionFeeQuery);

    // Get current default broker commissions
    final List<DefaultBrokerCommission> currentDefaults =
        commissionService.loadDefaultBrokerCommissions(
            broker, DefaultBrokerCommission.Relationships.BROKER_COMMISSION);

    // Prepare list to JSP
    final List<DefaultBrokerCommission> defaultBrokerCommissions =
        buildCommissions(groupCommissions, currentDefaults);

    request.setAttribute("broker", broker);
    request.setAttribute("defaultBrokerCommissions", defaultBrokerCommissions);
    RequestHelper.storeEnum(request, BrokerCommission.When.class, "whens");
    RequestHelper.storeEnum(request, Amount.Type.class, "amountTypes");
  }