Example usage for org.springframework.web.bind ServletRequestUtils getDoubleParameter

List of usage examples for org.springframework.web.bind ServletRequestUtils getDoubleParameter

Introduction

In this page you can find the example usage for org.springframework.web.bind ServletRequestUtils getDoubleParameter.

Prototype

@Nullable
public static Double getDoubleParameter(ServletRequest request, String name)
        throws ServletRequestBindingException 

Source Link

Document

Get a Double parameter, or null if not present.

Usage

From source file:com.springsource.greenhouse.home.UserLocationHandlerInterceptor.java

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    Double latitude = ServletRequestUtils.getDoubleParameter(request, "latitude");
    Double longitude = ServletRequestUtils.getDoubleParameter(request, "longitude");
    if (latitude != null && longitude != null) {
        request.setAttribute(USER_LOCATION_ATTRIBUTE, new Location(latitude, longitude));
    }//w w w  .  j  a v a  2s  .c  o m
    return true;
}

From source file:net.sourceforge.subsonic.backend.controller.IPNController.java

private void processSubscriptionPayment(HttpServletRequest request) throws ServletRequestBindingException {
    String subscrId = request.getParameter("subscr_id");
    String payerId = request.getParameter("payer_id");
    String btnId = request.getParameter("btn_id");
    String ipnTrackId = request.getParameter("ipn_track_id");
    String txnId = request.getParameter("txn_id");
    String currency = request.getParameter("mc_currency");
    String email = request.getParameter("payer_email");
    Double amount = ServletRequestUtils.getDoubleParameter(request, "mc_gross");
    Double fee = ServletRequestUtils.getDoubleParameter(request, "mc_fee");
    Date created = new Date();

    LOG.info("Received subscription payment of " + amount + " " + currency + " from " + email);

    subscriptionDao.createSubscriptionPayment(new SubscriptionPayment(null, subscrId, payerId, btnId,
            ipnTrackId, txnId, email, amount, fee, currency, created));

    // Extend subscription validity with one year.
    Subscription subscription = getOrCreateSubscription(request);
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.YEAR, 1);/* ww w  .  j  a  v  a2  s . c  o  m*/
    subscription.setValidTo(cal.getTime());
    subscription.setUpdated(new Date());
    subscriptionDao.updateSubscription(subscription);
}