| How to check if parameter was set (Birt 2.1.1) [message #194483] |
Tue, 10 October 2006 06:16  |
|
Originally posted by: fake.mail.pl
Hi!
I want to switch to birt version 2.1.1 (I was using birt 2.0.1 and have
switched to birt 2.1.0) but some scripts that have worked in previous
versions don't work in the newest :/
1st problem:
In report I specify a parameter of type DateTime and allow it to be null
value. I don't set any default value too. In the initialize section of the
report I use script like:
if (params["dateBegin"] == null) {
params["dateBegin"] = new Date();
}
That code worked in 2.0.1 and in 2.1. However in 2.1.1 it never executes
the statement "params["dateBegin"] = new Date();" as if
params["dateBegin"] is always different than null! So, how can I check if
report parameter was entered ?
2nd problem:
I changed the script to always do "params["dateBegin"] = new Date();"
statement. I insert a report element of type Text and set its value to
"dateBegin=<VALUE-OF format="yyyy-MM-dd">params["dateBegin"]</VALUE-OF>".
When report executes, the text element doesn't display current date but
something like:
"org.mozilla.javascript.NativeDate@ea355f"
Again in the previous versions of birt there was no problems :/
Can anybode help me how to fix this to work correctly ?
--
Adam
|
|
|
|
| Re: How to check if parameter was set (Birt 2.1.1) [message #194651 is a reply to message #194536] |
Wed, 11 October 2006 03:32   |
|
Originally posted by: fake.mail.pl
Jason Weathersby wrote:
> Add .value to the references to params["dateBegin"] reference.
> So
> if (params["dateBegin"].value == null) {
> params["dateBegin"].value = new Date();
> }
> <VALUE-OF format="yyyy-MM-dd">params["dateBegin"].value</VALUE-OF >"
Thank you, that works :)
I have another question :)
In Birt 2.1.1 when declaring DataSet I can define a parameter in
"Parameter" section. There for a date parameter in column "Data Type" i
choose "DateTime". Next, in column "Linked To Report Parameter" I choose
"dateBegin". If I don't set that parameter when running a report (the
script sets it the way you have suggested) the report shows an error "Can
not convert the value of org.mozilla.javascript.NativeDate@1845d4 to Date
type". The solution to this is to set "Default Value" column in defining a
sql query parameter to params["dateBegin"].value. However it seems for me
this isn't a clean and elegant solution: why there is "Linked To Report
Parameter" column if I cannot use it if I set a parameter value (of type
DateTime) by script ? Maybe there is a better way to do this, or in next
version of birt that issue will be corrected ?
--
Adam
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01779 seconds