Pergunta

i have a grails controller action like this.....

Controller : Home.groovy

def search(){

        def pl=Long.valueOf(params.pl).longValue(); println pl 

        def mil=Long.valueOf(params.mil).longValue(); println mil
        def mal=Long.valueOf(params.mal).longValue(); println mal

        def mic=Long.valueOf(params.mic).longValue(); println mic

        def mac=Long.valueOf(params.mac).longValue(); println mac


        def mib=Long.valueOf(params.mib).longValue(); println mib
        def mab=Long.valueOf(params.mab).longValue(); println mab


        Type pt=Type.valueOf(params.pt); println pt

            def results=Project.executeQuery("""
              select new map (prt.name as name,pp.id as propertyId,pp.constructedSize as constructedSize,
                 prt.propertyLocation.name as location,pp.mrp as mrp,pp.landSize as landSize,
                    pp.propertyType.name as propertyType)
                      from Project prt
                         JOIN prt.projectProperties pp where 
                           pp.propertyType.name=:pt and
                              pp.constructedSize between :mic and :mac and
                                pp.landSize between :mil and :mal and
                                   pp.mrp between :mib and :mab and
                                      prt.propertyLocation.id=:pl       
                        """,[mic:mic,mac:mac,mil:mil,mal:mal,mib:mib,mab:mab,pl:pl,pt:pt])
        println results

        def customerInstance=new Customer()
        render (view:'search',model:[results:results as JSON,customerInstance:customerInstance])
    }

and the view rendered from this action is given below only the part in which there is a error...

View : Search.gsp

<table style="width: 50%;">
        <g:each in="${results}" var="item">
            <tr>
                <td><div class="box shadow-outside-all" >
                   <input type="checkbox" name="getInterest" id="getInterest"
                    value="${item.propertyId}" style="float: left;" /> 
                    <b> ${item.name?.encodeAsHTML()}</b></br>
                    Property Type: ${item.propertyType?.encodeAsHTML()}</br> 
                    Constructed Size:${item.constructedSize?.encodeAsHTML()}</br> 
                    Land Size: ${item.landSize?.encodeAsHTML()}</br>
                    MRP: ${item.mrp?.encodeAsHTML()}</br> 
                    Location: ${item.location?.encodeAsHTML()}</br>
                   </div>
                </td>
            </tr>
        </g:each>
        <br />

    </table>

and the error is...

Error

No such property: propertyId for class: grails.converters.JSON. Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error evaluating expression [item.propertyId] on line [144]: No such property: propertyId for class: grails.converters.JSON
    at E__Yogesh_development_work_client_okruti_propertyHub_grails_app_views_home_search_gsp$_run_closure2.doCall(search.gsp:144)
    at E__Yogesh_development_work_client_okruti_propertyHub_grails_app_views_home_search_gsp.run(search.gsp:216)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:200)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
    at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
    at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: groovy.lang.MissingPropertyException: No such property: propertyId for class: grails.converters.JSON
    at E__Yogesh_development_work_client_okruti_propertyHub_grails_app_views_home_search_gsp$_run_closure2_closure21.doCall(search.gsp:144)
    ... 10 more

Any help would be appreciated.....

Foi útil?

Solução

Why are you rendering your results as JSON like that? Don't render them as JSON. Your GSP is expecting a map/model not JSON results.

From your controller render your results like this instead:

render(view:'search', model:[
  results:results,
  customerInstance:customerInstance
])
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top