Share on Google+Share on Google+

basha
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me
3 Answer(s)      3 years and 5 months ago
Posted in : JavaScript Questions

Hi have develop the jsp to populate related birds whenever we give input in the text field. But i am getting the wrong bird value in the text filed.

MultipleRemote.java :

  package net.viralpatel.spring.autocomplete;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class MultipleRemote {

    @RequestMapping(value = "/mr", method = RequestMethod.GET)
    public ModelAndView index() {

        ModelAndView mv=new ModelAndView();
        mv.setViewName("MultipleRemote");
        return mv;
    }

    @RequestMapping(value = "/birds", 
                    method = RequestMethod.GET, 
                    headers="Accept=*/*")
    public @ResponseBody List<String> getCountryList(@RequestParam("term") String query) {
        List<String> list = new ArrayList<String>();
        list.add("parrot");
        list.add("crow");
        list.add("dove");
        System.out.println("list="+list);
        return list;
    }
}

MultipleRemote.jsp:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Autocomplete - Multiple, remote</title>

<link rel="stylesheet"
    href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />

<script>

$(function() {
    $( "#birds" ).autocomplete({
        source: '${pageContext. request. contextPath}/birds.html'
    });
});

</script>
</head>
<body>
    <div class="ui-widget">
        <label for="birds">Birds: </label> <input id="birds" size="50" name="term" />
    </div>
</body>
</html>

Problem: whenever we send the request to server with http://localhost:8089/Spring3MVCMultipleRow_Submit/mr.html url, the controller is sending request to MultipleRemote.jsp. If whenever i type message like "pa" in the text filed then the text filed is successfully populated all bird names , but whenever i selected any bird in the text filed the am getting the result in text field like "birdname," . Hear i am not getting why the "," is appending to bird name.

How can i get only bird name without "," in the text filed?.

Please help me

Thanks...

Ads

View Answers

November 15, 2013 at 10:44 AM


Thanks lot



November 6, 2013 at 9:03 PM


Hi Basha,

I saw your problem today itself. If you still facing the same issue.I can suggest you to go through the below URL where i given good example with code snippets.

Let me know if you have any issues further. Ajax Request Processing using Spring with Auto Complete Example
Thank You.



November 6, 2013 at 9:03 PM


Hi Basha,

I saw your problem today itself. If you still facing the same issue.I can suggest you to go through the below URL where i given good example with code snippets.

Let me know if you have any issues further. Ajax Request Processing using Spring with Auto Complete Example
Thank You.










Related Tutorials/Questions & Answers:
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads