Example usage for org.apache.wicket.util.string StringValue toDouble

List of usage examples for org.apache.wicket.util.string StringValue toDouble

Introduction

In this page you can find the example usage for org.apache.wicket.util.string StringValue toDouble.

Prototype

public final double toDouble() throws StringValueConversionException 

Source Link

Document

Convert this text to a double.

Usage

From source file:org.antbear.jee.wicket.GeolocationAjaxBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {
    log.debug("respond");

    Request request = RequestCycle.get().getRequest();
    IRequestParameters requestParameters = request.getRequestParameters();

    StringValue svStatus = requestParameters.getParameterValue("status");
    if (svStatus == null || svStatus.isNull() || svStatus.isEmpty())
        throw new RuntimeException("Invariant violation: status is a required parameter");
    Integer status = svStatus.toInteger();

    if (status == 0) {
        StringValue svMessage = requestParameters.getParameterValue("msg");
        if (svMessage == null || svMessage.isNull() || svMessage.isEmpty())
            throw new RuntimeException("Invariant violation: message is a required parameter");

        log.debug("Geolocation failed: " + svMessage.toString());
        onError(target, svMessage.toString());

    } else {/*from  w  w  w  .  ja va  2  s .c om*/
        StringValue svLatitude = requestParameters.getParameterValue("lat");
        if (svLatitude == null || svLatitude.isNull() || svLatitude.isEmpty())
            throw new RuntimeException("Invariant violation: message is a required parameter");

        StringValue svLongitude = requestParameters.getParameterValue("lon");
        if (svLongitude == null || svLongitude.isNull() || svLongitude.isEmpty())
            throw new RuntimeException("Invariant violation: message is a required parameter");

        log.debug("Geolocation received: lat " + svLatitude.toDouble() + ", lon " + svLongitude.toDouble());
        onLocation(target, svLatitude.toDouble(), svLongitude.toDouble());
    }
}