Jump to content

Field value not being passed to subreport


mc53

Recommended Posts

HI All,

I have a main report with a query that gets a field called $F{PRESENCE}.  I would like to pass this as a parameter to a subreport to display it in a field with a default value ($P{PRESENCE}).  I have created a working report that does this in ireport.  I can run it successfully in ireport or from the repository in ireport.  The problem occurs when I try to run the report directly from the repository via my browser.  I get either the error: 08:50:05,168 ERROR JSErrorPage_jsp,http-8080-1:339 -
net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
         1. Field not found : PRESENCE

or a null value.

I've tried creating the input control on the subreport through the repository, but that didn't work.  I tried assigning the default value ($F{PRESENCE}) on both the main report parameter (this gave a null value on the main report) and on the subreport (this worked in ireport but not in the repository via browser).  How can I get the result of an sql field to display on a subreport?

I know I am having this problem because I have little or no reference resources, so to ask a secondary question, which resource do you think is most useful in these kinds of situations?

Thanks

MC53

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

1. first you have create a parameter value in subreport

2. when you include this subreport into the main report (i.e. drag from the report element ).

Use an existing report and browse to that location where subreport is located. after this click on next button then select the datasource after that you have to select the report parameter expression (this is place where you can set the subreport parameter to the value getting from the sql of java code)

 

Link to comment
Share on other sites

Yes I have done that:

<subreport>
                <reportElement x="51" y="12" width="944" height="100"/>
                <subreportParameter name="taxon"/>
                <subreportParameter name="presence">
                    <subreportParameterExpression><![CDATA[$F{PRESENCE}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[java.sql.DriverManager.getConnection("jdbc:oracle:thin:@servername:port:DEV", "username", "passowrd")]]></connectionExpression>
                <subreportExpression class="java.lang.String"><![CDATA["C:\\Program Files\\jasperserver-3.5.0\\samples\\reports\\dao_test.jasper"]]></subreportExpression>
            </subreport>

I should mention, I have tried with subreport expression repo:/path/dao_test and the report either runs with null values or throws a compile error on the prameter presence.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...