0

So, I have created a simple CRUD app using groovy on grails and I want to use jasper reporting plugin to get some simple reports on the database. I have set up a simple G:select to pick from a drop down list, and hitting the PDF icon I am bringing back a blank page. gsp is below

<div id="page-body" role="main">
<p>Please select one of the following options</p>
<div>
<g:select optionKey="id" 
optionValue="artist" 
name="artist" 
id="MusicCatalogue" 
value="${artist}" 
from="${multicatalogue.MusicCatalogue.list()}">
</g:select>
</div>
<div> <g:jasperReport jasper="report1" format="PDF" name="Music Catalogue" />
<input type="hidden" name="artist" value="${artist}" />
</div>
</div>

and then the jrxml looks like the below

<parameter name="artist" isForPrompting="true" class="java.lang.String">
    <defaultValueExpression><![CDATA["<parameter error>"]]></defaultValueExpression>
    </parameter>
    <queryString language="SQL">
        <![CDATA[SELECT   *
    FROM
    MusicCatalogue where ARTIST = $P{artist}]]>
    </queryString>
    <field name="ID" class="java.lang.Integer"/>
    <field name="ALBUM" class="java.lang.String"/>
    <field name="ARTIST" class="java.lang.String"/>
    <field name="TRACK" class="java.lang.String"/>
    <group name="ARTIST">

ideas????

4

1 回答 1

0

Try replace

<g:jasperReport jasper="report1" format="PDF" name="Music Catalogue" />
<input type="hidden" name="artist" value="${artist}" />

With

<g:jasperReport jasper="report1" format="PDF" name="Music Catalogue">
<input type="hidden" name="artist" value="${artist}" />
</g:jasperReport>

Also, make sure that ${artist} returns a string value, else the report will use the defaultValue of artist parameter that might ruin your query.

于 2013-02-18T01:59:48.297 回答