@Override
  protected void prepareForm(final ActionContext context) throws Exception {
    final HttpServletRequest request = context.getRequest();
    final EditCreditLimitForm form = context.getForm();
    final long id = form.getMemberId();
    if (id <= 0L) {
      throw new ValidationException();
    }
    final Member member = elementService.load(id, Element.Relationships.USER);
    final CreditLimitDTO creditLimit = accountService.getCreditLimits(member);

    // Transform positive to negative values to pass to the JSP
    Map<? extends AccountType, BigDecimal> limitPerType = creditLimit.getLimitPerType();
    final Map<AccountType, BigDecimal> newLimitPerType = new HashMap<AccountType, BigDecimal>();
    for (final AccountType accountType : limitPerType.keySet()) {
      BigDecimal limit = limitPerType.get(accountType);
      if (limit != null && limit.compareTo(new BigDecimal(0)) == 1) {
        limit = limit.negate();
      }
      newLimitPerType.put(accountType, limit);
    }
    limitPerType = newLimitPerType;
    creditLimit.setLimitPerType(limitPerType);

    request.setAttribute("member", member);
    request.setAttribute("limits", creditLimit.getEntries());
  }
 @Override
 protected ActionForward handleSubmit(final ActionContext context) throws Exception {
   final EditCreditLimitForm form = context.getForm();
   final CreditLimitDTO creditLimit = getDataBinder().readFromString(form);
   accountService.setCreditLimit(getMember(form), creditLimit);
   context.sendMessage("creditLimit.modified");
   return ActionHelper.redirectWithParam(
       context.getRequest(), context.getSuccessForward(), "memberId", form.getMemberId());
 }
 /** @param form */
 private Member getMember(final EditCreditLimitForm form) {
   return EntityHelper.reference(Member.class, form.getMemberId());
 }