Mercurial > hg > LGServices
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/methods/searchAutocomplete.jsp Thu Apr 23 15:46:01 2015 +0200 @@ -0,0 +1,38 @@ +<%@page import="java.util.List"%> +<%@page import="de.mpiwg.gazetteer.utils.DBService"%> +<%@page import="org.json.JSONObject"%> +<%@page import="org.json.JSONArray"%> +<% + + String term = request.getParameter("term"); + String searchIn0 = request.getParameter("searchIn"); + Integer searchIn = 0; + try{ + searchIn = Integer.parseInt(searchIn0); + }catch(Exception e){} + + + + List<String> list = null; + + if(searchIn == 0){ + System.out.println("By Section"); + list = DBService.suggestSectionName(term, 10); + }else{ + System.out.println("By Book"); + list = DBService.suggestBookName(term, 10); + } + + System.out.println("AutoComplete: " + term + " " + list.size()); + + JSONArray jsonArr = new JSONArray(); + + for(String item : list){ + JSONObject json = new JSONObject(); + json.put("name", item); + json.put("value", item); + jsonArr.put(json); + System.out.print("*"); + } + out.println(jsonArr); +%> \ No newline at end of file