Sara
Sara

Reputation: 11

Best practices for passing params in Grails 3

I'm building a Grails application that starts with loading XML file and based on it generates (dynamically) a form that has checkboxes and a submit button. When a user submits a form, a controller receives the params (checkboxes) and calls a method that reads an Excel file to extract records that matches the params.

In other words, the scenario I'm trying to implement is that the user submits a form that has some checkboxes (generated dynamically from an XML file), and the params will be passed to a controller that runs a script or a service, which uses these params as criteria to retrieve some rows from an xlsx file and displays these rows in a view.

My question is what are the best practices for doing that?

Also, what is the most efficient way to parse an Excel or CSV file and extract records with data that match the params? (I can't use DB or domain classes because the Excel file can be updated with new columns over time).

Upvotes: 0

Views: 659

Answers (1)

elixir
elixir

Reputation: 1442

params in Grails do a good job. However, I would suggest that you consider using command objects. Command objects are like Grails domains but they do not persist data in a physical database. You can easily pass the instantiated command object to the external groovy class (in the src folder) instead of passing params.

You can find more details here: http://guides.grails.org/command-objects-and-forms/guide/index.html

Upvotes: 2

Related Questions