2
votes

First let me say that my question is slightly different from some similar ones already on SO, or at least different enough that other answers are not helping me. E.g.,: JasperReport parameters works in iReport but fails on JasperServer There are others dealing with timestamp problems that also haven't helped me.

I'm a newbie to JasperReports. The question linked above was solved by adding input controls to the report definition in iReport, which would then be exported to JasperServer. That much works fine for me.

My problem is with a report having a query with a timestamp parameter and an input control. I have assigned a default value of java.sql.Timestamp(0) to the parameter. Everything works fine when I open iReport and generate the report using the "Run on JasperServer" option, the input control shows up with the proper default value. However if I run the same report from a browser connection the default values don't work. The controls show up with defaults of some date, I think, in 1969. The input controls still work, can enter a value and the report runs properly, but the browser input controls don't get the default value.

I suspect the problem may arise because the input controls are defined as having datatype of datetime, not timestamp. However if that's the case I can't figure out why the defaults work fine in the input controls in iReport but not when the report is run from the browser. I've read various posts where someone has said that java.sql.Timestamp was not supported by JasperServer before ver 3.5. I'm using most recent version but I still can't figure out how to add a timestamp type to the server repository (or whether it's necessary, since things seem to work fine with datetime type other than my problem with default values).

1
What value do you want to have as your default? Apparently JasperServer is corresponding the the default of 0 to 1969. What exactly do you want it to be?Tom
Thanks, wanted current date as default. My main issue was that JasperServer was handling it differently from iReport. Was probably my own inexperience with Java and JasperServer that was fouling things up. I got better setup going with date parameter that's used for input control prompt, but with query using a string parameter (with 'isForPrompting="false") that has default expression accessing the date control input. Works fine in both iReport and on browser with JasperServer.Herbert Sitz

1 Answers

0
votes

For the current date as default you can use this function in Ireport

  new java.util.Date()

it gives you current date and i have tested it also works fine with Jasper server browser.