Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How to check if parameter was set (Birt 2.1.1)
How to check if parameter was set (Birt 2.1.1) [message #194483] Tue, 10 October 2006 10:16 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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
>
Re: How to check if parameter was set (Birt 2.1.1) [message #696101 is a reply to message #194725] Wed, 13 July 2011 09:22 Go to previous messageGo to next message
arlene86  is currently offline arlene86 Friend
Messages: 6
Registered: July 2011
Junior Member
Hi,

I need some help here.
How to allow blank for parameter datatype = datetime?
If i let the parameter blank, i got popup message "The parameter "date" cannot be blank" ..

Arlene
Re: How to check if parameter was set (Birt 2.1.1) [message #1715718 is a reply to message #194483] Wed, 25 November 2015 13:04 Go to previous message
Md. Atequer Rahman is currently offline Md. Atequer RahmanFriend
Messages: 1
Registered: November 2015
Junior Member
I am also facing same problem. My code is:

if(dataSetRow["Kuvaus 3"].value != null){
dataSetRow["Kuvaus 3"] +" "+dataSetRow["ITEM_INFO"];
} else {
dataSetRow["Kuvaus 3"];
}
After running report following error message is shown.
TypeError: Cannot read property "value" from null
Waiting for your kind response.
Previous Topic:PERCENTSUM does not work?
Next Topic:runtime problem after migration
Goto Forum:
  


Current Time: Fri Apr 19 05:22:25 GMT 2024

Powered by FUDForum. Page generated in 0.01436 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top