I’ve set up a search page in my Grails application using the searchable plug-in. My search is working fine but I’m running into a small problem. In my search results (which display a name and a state), the state is not showing up.
I have two domains:
class Person {
String firstName
String lastName
State state
}
class State {
String name
String code
String toString()
return this.name
}
}
In my search.gsp view, I have the following:
<g:each var="result" in="${searchResult.results}">
<div class="searchResult">
<div class="searchPerson">
<g:link controller="person" action="show" id="${result.id}">
${result.lastName}, ${result.firstName}
</g:link>
</div>
<div class="searchAddress">
${result.state}
</div>
</div>
</g:each>
How come my state name is not showing up? I’ve tried the following:
- ${result.state.name}
- ${result.state.code}
- ${result.state.toString()}
I’m sure the issue is a small one but, as a Grails newcomer, I can’t seem to figure it out. I’d appreciate any help!
Found this (Eager fetching and searchable plugin in Grails), seems like what is causing the problem, hope your problem gets resolved.