简体   繁体   中英

How to retain Form Parameters in Grails

I have a similar problem here. I have a page which accepts 3 parameters. i enter the parameters and the control goes to the list action. The list action has the code to query db and get the data on list.gsp page. Now when i hit "download to excel" on the same page, i want the same list action to get triggered and the same query to be run. However, when I click on "export to Excel", control goes to the list action, but the data that i had entered for my query to run is now null. The form elements have not been retained. Please help.

I am using the export plugin

Pass the same parameter values back to the controller when the export button is clicked, send them back to the page as "listParams"

[ bookInstanceList: Book.list( params ), listParams: params ]

I might also suggest that you have a different action handle the click on the export button since you really do not want to list the data, you want to export it.

The formats tag supports the following attributes and allows you to pass through HTML attributes:

  • formats (Formats which should be displayed, List of Strings, eg ['csv', 'excel', 'ods', 'pdf', 'rtf', 'xml'])
  • params (Additional request
  • parameters, Map, eg [sort:params?.sort, order: params?.order])
  • action (Action which should be called, defaults to current action)
  • controller (Controller which should be called, defaults to current controller)

http://www.grails.org/plugin/export

<export:formats params="${listParams}"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM