0
votes

Trying to use g:include on a grails 3.1.10 app and it seems:

This appears to pass id through ok

<g:include action="show" id="${currentBook.id}" />

Trying to pass params over though (nothing seems to get through):

<g:include action="list" params="[sort: 'title', order: 'asc',
                                  author: currentBook.author]" />

Just wondered if it was a form of a bug fixed in a later version and if so which version ?

Ahh it may be a bug in later versions too, my params had a dot

 <g:include action="list" params="['sort.id': 'title']" />

When i try it with a .something it returns nothing as a params

e2a

I can confirm it is happening under grails 3.27, I will file a bug:

Assuming we have a controller like this:

class TestController {

def index() { }

    def test1() {
            println "params are $params"
            render params
    }
    def test2() {
            println "params are $params"
            render params
    }

}

and a gsp index page of this:

   <html>
<head>
    <meta name="layout" content="main"/>
</head>


<g:include action="test1" params="${[id:1L]}"/>
<g:include action="test1" params="[id:2L]"/>
----<br>
<g:include action="test2" params="${['field.id':3L]}"/>
<g:include action="test2" params="['field.id':4L]"/>
<g:include action="test2" params="[fieldId:5L]"/>
<g:include action="test2" params="${['fieldId':6L]}"/>

As below shows 3L and 4L which are field.id do not appear to show up in println or render statements of above controller action

debug printlns

 params are [id:1, action:test1, format:null, controller:test]
params are [id:2, action:test1, format:null, controller:test]
params are [action:test2, format:null, controller:test]
params are [action:test2, format:null, controller:test]
params are [fieldId:5, action:test2, format:null, controller:test]
params are [fieldId:6, action:test2, format:null, controller:test]

Html output from controller:

['id':'1', 'action':'test1', 'format':null, 'controller':'test'] 
['id':'2', 'action':'test1', 'format':null, 'controller':'test'] ----

['action':'test2', 'format':null, 'controller':'test'] 
['action':'test2', 'format':null, 'controller':'test'] 
['fieldId':'5', 'action':'test2', 'format':null, 'controller':'test'] 
['fieldId':'6', 'action':'test2', 'format':null, 'controller':'test']
1
Verify the issue exists with 3.2.7 and if it does, file a report on github - James Kleeh

1 Answers

0
votes

I haven't tried it in grails 3 but in grails 2 you had to put params value in ${} in your case params="${['sort.id': 'title']}"