2
votes

I am creating a basic report wherein I could pass the domain model passed by the controller to the view and use that instance as a parameter for the report.

Here the part of the <g:jasperReport> in the view[.gsp]

Note: ${user} is an instance of User inside the domain classes having those string properties: lastName, firstName, middleName

<g:jasperReport 
  jasper="reportByUser"
  format="pdf, html">
    <input type="hidden" name="u_lastName" value="${user.lastName}" />
    <input type="hidden" name="u_firstName" value="${user.firstName}" />
    <input type="hidden" name="u_middleName" value="${user.middleName}" />
</g:jasperReport>

Here the part of the xml code inside the reportByUser.jrxml

<parameter name="user_lastName" class="java.lang.String" />
<parameter name="user_firstName" class="java.lang.String" />
<parameter name="user_middleName" class="java.lang.String" />

The problem is when I run the report on the grails, either format return a blank page.

1

1 Answers

0
votes

In:

<g:jasperReport 
  jasper="reportByUser"
  format="pdf, html">
    <input type="hidden" name="u_lastName" value="${user.lastName}" />
    <input type="hidden" name="u_firstName" value="${user.firstName}" />
    <input type="hidden" name="u_middleName" value="${user.middleName}" />
</g:jasperReport>

You are passing: name="u_lastName"

But in the jasper file is specting: name="user_lastName"

Check it...