How to check if parameter was set (Birt 2.1.1) [message #194483] |
Tue, 10 October 2006 10:16 |
Eclipse User |
|
|
|
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 #194536 is a reply to message #194483] |
Tue, 10 October 2006 17:24 |
|
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 >"
Jason
"Adam" <fake@mail.pl> wrote in message
news:9b1d56104cd4e56065aceb157048afb2$1@www.eclipse.org...
> 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 07:32 |
Eclipse User |
|
|
|
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
|
|
|
Re: How to check if parameter was set (Birt 2.1.1) [message #194725 is a reply to message #194651] |
Wed, 11 October 2006 15:38 |
|
This is an order of execution problem. If you want to set it as part of a
script you have
select none on the link to report parameter and enter an expression like:
if (params["dt1"].value == null) {
params["dt1"].value = new Date();
}
params["dt1"].value
You can log a bugzilla entry to improve this if you would like.
Jason
"Adam" <fake@mail.pl> wrote in message
news:b855b96d808023af1908d14892a72498$1@www.eclipse.org...
> 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.02893 seconds