Jump to content
Changes to the Jaspersoft community edition download ×

Mapping Input Controls to iReport queries.


ccmorten

Recommended Posts

Hi,

1. I have added an Input control called startdate in JasperServer with a single select query to give the user a selection of dates to choose from.

The query looks like this (query inside the input control):

select distinct recordtimestamp from calltypedaily
order by recordtimestamp asc

recordtimestamp is an sql datetime from an SQL Server

In iReport I have a java.util.Date parameter called startdate, which I use to compare two dates in my iReport query:

select ....
from .....
where recordtimestamp between $P{startdate} and $P{enddate}

When I used an input control of type date, there was no problem, but when I use a single-select query to populate my combobox the date is converted to a string. How do I convert it back to a date format, so I can do the date comparison?

 

2. What kind of parameter type does a multi-select query Input Control return? Should I make it a Collection parameter or a List parameter, and how do I convert it back to the type I need in my iReport query?

 

Thanks for your reply.

Best regards,

CC:Morten

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

1.

Option 1: use SQL to convert your data from string to datr
Option 2: use a second parameter which convert the string in a date:

Param1 = String, Param2 = java.util.Date
Param2 default value expression:   new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse( $P{param1})

2. java.util.Collection

in your query use the special syntax:

$X{IN, query_field, parameter)

i.e.  SELECT * from ORDERS where $X{ IN, shipcity, selecedCities }

Giulio

Link to comment
Share on other sites

Hmm, I've tried doing this both ways and for some reason i'm still getting errors, if I set my parameter as a string I get

java.lang.ClassCastException: java.lang.String

 

If I set it as a collection I get

 

com.jaspersoft.jasperserver.api.JSExceptionWrapper: Errors were encountered when compiling report expressions class file: 1. Cannot cast from String to Collection value = (java.util.Collection)("");//$JR_EXPR_ID=0$ <------------------------> 2. Cannot cast from String to Collection value = (java.util.Collection)("");//$JR_EXPR_ID=0$ <------------------------> 3. Cannot cast from String to Collection value = (java.util.Collection)("");//$JR_EXPR_ID=0$ <------------------------> 3 errors

 

I am using a multi-select query control that selects names from a table of names, and I am trying to return rows which contain the names I've selected

The Actual type of the field returned for the control is varchar2




Post Edited by gsxstylee at 08/07/2009 15:46
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...