Quantcast

Newbie, help with search

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Newbie, help with search

lynchd1
This post has NOT been accepted by the mailing list yet.
Hi,
Apologies in advance for the newbie question but I'm trying to implement a search with HQL and my params field back to the controller is passing null:

DomainClass:
class Emcint_ach_edi_payments {
        static searchable = true
       
    static constraints = {
                emc_country(blank:false)
                file_type(blank:false)
                creation_date(blank:false)
                bank_account_num()
                file_reference()
    }
       
        String emc_country
        String file_type
        Date creation_date
        String bank_account_num
        String file_reference
}

list.gsp:
<g:form name="searchForm">
        <input type="text" value="searchQuery"/>
        <g:actionSubmit value="Search By Reference" action="refSearch"/>
</g:form>

Controller:
class Emcint_ach_edi_paymentsController {
       
        def scaffold = Emcint_ach_edi_payments
       
        def refSearch = {
                def payList = Emcint_ach_edi_payments.findAll("from Emcint_ach_edi_payments as b " +
                                "where b.file_reference like ?",["%${params.searchQuery}%"])
                render(view:'list',model:[payList: payList])
                println("%${params.searchQuery}%")
                println("${payList}")
        }
}

Output to console:
null
[]

Using the above setup the params.searchQuery is passing null back to the controller which is causing a null list output. The backend DB is Oracle 9i but dont think that should matter.

Any help would be greatly appreciated & thanks again

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Newbie, help with search

sdthomas
This post has NOT been accepted by the mailing list yet.
Try println(params.searchQuery) to see if the parameter has a value.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Newbie, help with search

lynchd1
This post has NOT been accepted by the mailing list yet.
just added that and its returning - null
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Newbie, help with search

lynchd1
This post has NOT been accepted by the mailing list yet.
Just wanted to update that I got a workaround to this issue. I'm using a more defined search definition:

<g:form url='[controller: "emcint_ach_edi_payments", action: "search"]'
        id="searchableForm"
        name="searchableForm"
        method="get">
  <g:textField name="q" value="${params.q}" size="10"/>
  <input type="submit" value="Search" />
</g:form>

def search = {
         render Emcint_ach_edi_payments.search(params.q, params)
}

Thanks again
Loading...