Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7839333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:24:36+00:00 2026-06-02T15:24:36+00:00

I’m learning myself Play 2.0 (Java API used) and would like to have a

  • 0

I’m learning myself Play 2.0 (Java API used) and would like to have a double/float parameter (for location coordinates), something like http://myfooapp.com/events/find?latitude=25.123456&longitude=60.251253.

I can do this by getting the parameters as String and parsing them at controller etc but can I use automatic binding here?

Now, I first tried simply having one double value:

GET     /events/foo                 controllers.Application.foo(doublevalue: Double)

with

public static Result foo(Double doublevalue) {
    return ok(index.render("Foo:" + doublevalue));
}

What I got was “No QueryString binder found for type Double. Try to implement an implicit QueryStringBindable for this type.”

Have I missed something already provided or
do I have to make a custom QueryStringBindable that parses Double?

I found some instructions on making a custom string query string binder with Scala at http://julien.richard-foy.fr/blog/2012/04/09/how-to-implement-a-custom-pathbindable-with-play-2/

What I tried:

I implemented DoubleBinder at package binders:

import java.util.Map;
import play.libs.F.Option;
import play.mvc.QueryStringBindable;

public class DoubleBinder implements QueryStringBindable<Double>{

    @Override
    public Option<Double> bind(String key, Map<String, String[]> data) {
        String[] value = data.get(key);
        if(value == null || value.length == 0) {
            return Option.None();
        } else {
            return Option.Some(Double.parseDouble(value[0]));
        }
    }

    @Override
    public String javascriptUnbind() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String unbind(String key) {
        // TODO Auto-generated method stub
        return null;
    }
}

And tried to add it to project/Build.scala’s main:

routesImport += "binders._"

but same result : “No QueryString binder found for type Double….”

  • I also changed the routing signature to java.lang.Double but that didn’t help either
  • I also changed the DoubleBinder to implement play.api.mvc.QueryStringBindable (instead of play.mvc.QueryStringBindable) both with Double & java.lang.Double at the routing signature but no help still
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:24:39+00:00Added an answer on June 2, 2026 at 3:24 pm

    Currently (in Play 2.0), Java binders only work with self-recursive types. That is, types looking like the following:

    class Foo extends QueryStringBindable<Foo> {
      …
    }
    

    So, if you want to define a binder for java.lang.Double, which is an existing type of Java, you need to wrap it in a self-recursive type. For example:

    package util;
    
    public class DoubleW implements QueryStringBindable<DoubleW> {
    
        public Double value = null;
    
        @Override
        public Option<DoubleW> bind(String key, Map<String, String[]> data) {
            String[] vs = data.get(key);
            if (vs != null && vs.length > 0) {
                String v = vs[0];
                value = Double.parseDouble(v);
                return F.Some(this);
            }
            return F.None();
        }
    
        @Override
        public String unbind(String key) {
            return key + "=" + value;
        }
    
        @Override
        public String javascriptUnbind() {
             return value.toString();
        }
    
    }
    

    Then you can use it as follows in your application:

    GET    /foo     controllers.Application.action(d: util.DoubleW)
    
    public static Result action(DoubleW d) {
          …
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
I would like to run a str_replace or preg_replace which looks for certain words
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.