Mercurial > hg > LGServices
comparison src/main/webapp/methods/searchAutocomplete.jsp @ 0:3e62083dbcbf
First commit. This project comes from LGServer. We removed the framework icefaces. Now, LGServices uses just JSP and jquery.
author | "jurzua <jurzua@mpiwg-berlin.mpg.de>" |
---|---|
date | Thu, 23 Apr 2015 15:46:01 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3e62083dbcbf |
---|---|
1 <%@page import="java.util.List"%> | |
2 <%@page import="de.mpiwg.gazetteer.utils.DBService"%> | |
3 <%@page import="org.json.JSONObject"%> | |
4 <%@page import="org.json.JSONArray"%> | |
5 <% | |
6 | |
7 String term = request.getParameter("term"); | |
8 String searchIn0 = request.getParameter("searchIn"); | |
9 Integer searchIn = 0; | |
10 try{ | |
11 searchIn = Integer.parseInt(searchIn0); | |
12 }catch(Exception e){} | |
13 | |
14 | |
15 | |
16 List<String> list = null; | |
17 | |
18 if(searchIn == 0){ | |
19 System.out.println("By Section"); | |
20 list = DBService.suggestSectionName(term, 10); | |
21 }else{ | |
22 System.out.println("By Book"); | |
23 list = DBService.suggestBookName(term, 10); | |
24 } | |
25 | |
26 System.out.println("AutoComplete: " + term + " " + list.size()); | |
27 | |
28 JSONArray jsonArr = new JSONArray(); | |
29 | |
30 for(String item : list){ | |
31 JSONObject json = new JSONObject(); | |
32 json.put("name", item); | |
33 json.put("value", item); | |
34 jsonArr.put(json); | |
35 System.out.print("*"); | |
36 } | |
37 out.println(jsonArr); | |
38 %> |