Skip to content
This repository
Browse code

Merge pull request #32 from adrnai/master

Issue #31
  • Loading branch information...
commit 2aa6bfbb055b5d01b7e1e6281e3a8062ee1b7dfe 2 parents 8980391 + bd320c4
Adrián iladriano authored
14 embedded-api/com/flaptor/indextank/api/resources/Autocomplete.java
@@ -20,6 +20,9 @@
20 20 import com.ghosthack.turismo.action.Action;
21 21
22 22 import javax.servlet.http.HttpServletResponse;
  23 +
  24 +import org.json.simple.JSONObject;
  25 +
23 26 import java.io.UnsupportedEncodingException;
24 27 import java.util.List;
25 28 import java.util.logging.Logger;
@@ -43,6 +46,7 @@ public void run() {
43 46
44 47 String query = params("query");
45 48 String field = params("field");
  49 + String callback = params("callback");
46 50
47 51 if (field == null || field.isEmpty()) {
48 52 field = "text";
@@ -50,7 +54,15 @@ public void run() {
50 54
51 55 List<String> complete = api.complete(query, field);
52 56
53   - print(complete.toString());
  57 + JSONObject json = new JSONObject();
  58 + json.put("query", query);
  59 + json.put("suggestions", complete);
  60 +
  61 + if(callback != null && !callback.trim().isEmpty()) {
  62 + print(callback.trim()+"("+json.toJSONString()+")");
  63 + } else {
  64 + print(json.toJSONString());
  65 + }
54 66
55 67 }
56 68

0 comments on commit 2aa6bfb

Please sign in to comment.
Something went wrong with that request. Please try again.