Hi All,
I am trying to include autocomplete option in my application and I want to get this while loading the page without any AJAX call. So, I am collecting all the details from DB and set it as a JSON string and passing it to my JSP.
In my JSP file, I am trying to get the values directly from that JSON string. But I am not getting the autocomplete option in my text box.
code to set it to JSON
while(voGroup.hasNext()){
dataMap = new HashMap();
// iterate over each row and add it to dataList
rGroup = voGroup.next();
dataMap.put("grpCd", rGroup.getAttribute("No"));
dataMap.put("grpDesc", rGroup.getAttribute("Name"));
dataList.add(dataMap);
}
dropdownDataMap.put("mainGrp", dataList);
response.setContentType("application/json");
java.io.PrintWriter out = response.getWriter();
request.setAttribute("mainGrpList", JSONValue.toJSONString(dataList));
==========================================
Code in JSP
It is inside Javascript code
var availableGrps = $("#mainGrpList").val();
$("#grpCodeLbl").autocomplete({
source: availableGrps
});
Please help me to find out the reason, why it is not coming in the page.
Regards,
Joby Joseph