1

I am using export plugin

compile ":export:1.5"

controller code:

def exportJson(){
    if(!params.max) params.max = 10

    if(params.formattext){
        response.contentType = grailsApplication.config.grails.mime.types[params.formattext]
        response.setHeader("Content-disposition", "attachment; filename=BookList.${params.formattext}")


        exportService.export(params.formattext, response.outputStream,Book.list(),[:], [:])
    }
    response action:'index'
}

Gsp Code :-

<g:link action="exportJson" params="[formattext:'json']" class="btn btn-primary btn-sm" style="margin-right: 30px; float: right; margin-top: 10px;" >Export Rules</g:link></div>

while i am trying to export book list in json file its giving me error

No bean named 'jsonExporter' is defined. Stacktrace follows:
Message: No bean named 'jsonExporter' is defined
2
  • You have : params="[formattext:'json']" ... According to grails.org/plugin/export formats (Formats which should be displayed, List of Strings, e.g. ['csv', 'excel', 'ods', 'pdf', 'rtf', 'xml']). I think if I understand correctly you are trying to export out to JSON ? or maybe you are confusing yourself and you mean to export JSON to CSV or pdf or something and formattext should be one of those instead
    – V H
    Mar 13, 2015 at 9:29
  • i want export in json format..
    – SAGAR MANE
    Mar 13, 2015 at 9:53

1 Answer 1

0

Assuming you are using the export plugin for Grails, you will need to implement your own JSON exporter. It's not included by default, but if you implement the Exporter interface and register it as a prototype bean in your Resources.groovy then you should be able to use your own JSON exporter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.