I am using grails 2.1.0. I have a autocomplete field in my view page. For autocomplete field I have used richui plugin. And the result is shown in the box. Now I want to work with the id of the value of that field not with the string. But I am failing to get / set the id. I have no idea how to get the id from that field. Can anyone please help me on this please. Here is my source code below :
my view page >>>
<g:form controller="autocomplete" action="doSomething">
<richui:autoComplete id="countryName" name="countryName" action="${createLinkTo('dir': 'autocomplete/searchCountry')}" />
<br/>
<g:submitButton name="doSomething" />
</g:form>
my controller action for autocomplete >>>
def searchCountry = {
def country = Country.findAllByNameLike("${params.query}%")
//Create XML response
render(contentType: "text/xml") {
results() {
country.each { countries ->
result(){
name(countries.name)
id(countries.id)
}
}
}
}
}
my desire action where I want to work with id >>>
def doSomething(){
def val = "Country Id is -- > " + params.countryName
render val
}