grailsgrails3json-view

Accessing controller params in json views in Grails


A controller using json views will call the json view corresponding to the controller method called when rendering domains.

I want however to pass the controller params to the json view in addition to the domains, to customize the way a domain is rendered.

A typical example of the use of such a feature is to either display the domains rendered in an index endpoint in a short or detailed way.

How can I make pass the controller params to the json view?


Solution

  • How can I make pass the controller params to the json view?

    You don't have to do anything. You can reference the params variable in a JSON view. We provide direct access that way.

    For more info, see the "Accessing The Request" section at http://views.grails.org/latest/.