Reputation: 71
I first tried this: Grails export plugin don't download any file, but it resulted nothing.
My Controller
// Export service provided by Export plugin
def exportService
def grailsApplication //inject GrailsApplication
...other code...
def index = {
if(!params.max)
params.max = 10
log.debug("Azienda is ${Azienda} or type ${Azienda.class}")
if(params?.format && params.format != "html") {
response.contentType = grailsApplication.config.grails.mime.types[params.format]
response.setHeader("Content-disposition", "attachment; filename=aziende.${params.extension}")
exportService.export(params.format, response.outputStream, Azienda.list(params), [:], [:])
}
[ aziendaList: Azienda.list( params ), filterParams: FilterPaneUtils.extractFilterParams(params) ]
}
My index.gsp
<r:require module="export"/>
...other code...
<export:formats />
My url link is this, azienda/index?format=excel&extension=xls
. I tried to change format with other variable; something like this, azienda/index?formatD=excel&extension=xls
.
And I changed my controller in this way:
if(params?.formatD && params.formatD != "html") {
response.contentType = grailsApplication.config.grails.mime.types[params.formatD]
response.setHeader("Content-disposition", "attachment; filename=aziende.${params.extension}")
exportService.export(params.formatD, response.outputStream, Azienda.list(params), [:], [:])
}
But, I got a 404 Page Not Found
.
Upvotes: 0
Views: 613
Reputation: 457
Add
compile ":export:1.5"
line in your project BuildConfig.groovy
file under plugins block and restart application.
Upvotes: 3