f_chas01 Posted June 29, 2011 Share Posted June 29, 2011 I have a simple question. I want to use a value provided by the user via Input Control in JasperServer for the defaultValueExpression in the jrxml report definition. Is it possible?In report jrxml it looks like: <defaultValueExpression><![CDATA["16.10."+(new Integer(Integer.valueOf($P{P_JAHR}).intValue() - 1).toString())]]></defaultValueExpression>P_JAHR is provided via Input Control. In iReport this construction works perfectly. But using the same report definition in JasperServer with Input Controls causes the following error:Code:com.jaspersoft.jasperserver.api.JSExceptionWrapper: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : "16.10."+(new Integer(Integer.valueOf($P{P_JAHR}).intValue() - 1).toString()) Link to comment Share on other sites More sharing options...
f_chas01 Posted July 6, 2011 Author Share Posted July 6, 2011 I am still trying to understand it. Does somebody have any experience with it? Link to comment Share on other sites More sharing options...
federico.cattozzi Posted July 7, 2011 Share Posted July 7, 2011 The order of Parameters is important.Read this case:http://jasperforge.org/plugins/espforum/view.php?group_id=112&forumid=102&topicid=42807&page=3#66420 Link to comment Share on other sites More sharing options...
f_chas01 Posted July 15, 2011 Author Share Posted July 15, 2011 I understand the importance of the parameter order. But still it is about a value of a parameter (which is defined in the XML report definition at the right place) used as a default value for another parameter (coming few lines after the first one). The problem is at the Input Control stage in the JasperReports Server.In iReport the value of the first parameter is defined by user before the evaluation of the second parameter which does not require an input control. So in iReport as soon as the first parameter is defined all depended parameters can be defined as well. In JasperReports Server the evaluation of the parameters which do NOT require an input control happens BEVOR the user defines the value of the defining parameter. So if I use the value of a defining parameter in the dependant parameter in an expression the value used is null.The use case scenario is when we have one parameter defined by the user via input control and several dependant parameters which do not require the input control and can be calculated from the first parameter. Simple Example: user is entering the year and we want to define as another parameter the last day of the previous year. How can we do it in JasperReports Server? Link to comment Share on other sites More sharing options...
mdahlman Posted July 19, 2011 Share Posted July 19, 2011 JRS's ability to set input controls' default values is pretty weak.Step 1: if you're a paying customer, be sure to log a case with technical support asking for this to be improved. That will raise its priority.Next, for your simple example you probably need to attack it like this:1. Param_Year is a text field or query or whatever is appropriate.2. Param_First_Day_of_Last_Year is a SQL query like this:SELECT Date( $P!{Param_Year} || '-01-01' ) - ( INTERVAL 1 Day) as the_day(That's not valid SQL... but the pseudo code should be clear enough.)Now the input control Param_First_Day_of_Last_Year will be a drop down with the value that you want. Granted, this is pretty kludgy. For a more elegant solution, see step 1. (Sorry)Regards,Matt Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now