Skip to main content



      Home
Home » Archived » BIRT » Modify global varaible
Modify global varaible [message #119262] Fri, 27 January 2006 17:49 Go to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

I have a global variable
var gtotalMales = 0, in the initialize method. I need to update the value
of this variable in the datasets method.
I tried setting gtotalMales = row["totalMaleExamined"]. The value of
gtotalMales is not changed

Thanks in advance
Re: Modify global varaible [message #119353 is a reply to message #119262] Sat, 28 January 2006 03:59 Go to previous messageGo to next message
Eclipse UserFriend
chandrika

In which dataset method you have this line of script?

gtotalMales = row["totalMaleExamined"].


Wenfeng

"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:0f39a6723398c65ae28b4d524a35f747$1@www.eclipse.org...
>I have a global variable
> var gtotalMales = 0, in the initialize method. I need to update the value
> of this variable in the datasets method.
> I tried setting gtotalMales = row["totalMaleExamined"]. The value of
> gtotalMales is not changed
>
> Thanks in advance
>
Re: Modify global varaible [message #119404 is a reply to message #119353] Sat, 28 January 2006 20:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

I have this in the beforeClose() method.

thanks
Chandrika
Re: Modify global varaible [message #119969 is a reply to message #119262] Mon, 30 January 2006 11:15 Go to previous messageGo to next message
Eclipse UserFriend
Try do this in the "initialize" method:
gTotalMales = 0;

When you use the "var" keyword the variable is declared as local to the
initialize method.

--
Gary Xue
Actuate Corporation - Product Development
BIRT Committer
"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:0f39a6723398c65ae28b4d524a35f747$1@www.eclipse.org...
> I have a global variable
> var gtotalMales = 0, in the initialize method. I need to update the value
> of this variable in the datasets method.
> I tried setting gtotalMales = row["totalMaleExamined"]. The value of
> gtotalMales is not changed
>
> Thanks in advance
>
Re: Modify global varaible [message #120117 is a reply to message #119969] Mon, 30 January 2006 13:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

I took out the var in the intialize method. But the value is still not
updated. In the beforeClose method of the dataset, i have
gtotalMales = row["totalMalesExamined"]

Thanks
Chandrika
Re: Modify global varaible [message #120387 is a reply to message #120117] Mon, 30 January 2006 13:20 Go to previous messageGo to next message
Eclipse UserFriend
Chandrika,

I dont believe you have access to the row data in the beforeClose. You
should have access to it in the onFetch method.

Jason

"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:1e10b720c85106d2c052692d3410bb07$1@www.eclipse.org...
>I took out the var in the intialize method. But the value is still not
>updated. In the beforeClose method of the dataset, i have
> gtotalMales = row["totalMalesExamined"]
>
> Thanks
> Chandrika
>
Re: Modify global varaible [message #120429 is a reply to message #120387] Mon, 30 January 2006 17:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

Jason,

gtotalMales = 1500, in the onFetch() method also didnot work.
The value is still not updated.

Chandrika
Re: Modify global varaible [message #120454 is a reply to message #120429] Mon, 30 January 2006 14:25 Go to previous messageGo to next message
Eclipse UserFriend
Chandrika,

Run this example and see if it works.

Jason

"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:b3aeaeb4a19a92059c82db8c698f086d$1@www.eclipse.org...
> Jason,
>
> gtotalMales = 1500, in the onFetch() method also didnot work.
> The value is still not updated.
>
> Chandrika
>
>
>
>
>


Re: Modify global varaible [message #120483 is a reply to message #120454] Mon, 30 January 2006 17:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

Jason,

Sorry, Iam using the WebNewsReader and dont see the attachment. Can you
email to cchopra@executivehealthexams.com

Thanks
Chandrika
Re: Modify global varaible [message #120579 is a reply to message #120483] Mon, 30 January 2006 20:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

Jason,

I included this in your example,

<text id="58">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[Value of my global
Variable is <VALUE-OF>gblcounter</VALUE-OF>]]></text-property>
</text>

The value printed out was 0. That means it really didnot change the value
of the global variable within the dataset.

Thanks
Chandrika
Re: Modify global varaible [message #121638 is a reply to message #120579] Tue, 31 January 2006 07:33 Go to previous messageGo to next message
Eclipse UserFriend
Chandrika,

If you are setting this on the onFetch method, it will only be called when
the table is binded to a data set.
If you put the same text you have below after the table it should work.

Jason

"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:c5041b3e6f5eae1de367e0feb604deef$1@www.eclipse.org...
> Jason,
>
> I included this in your example,
>
> <text id="58">
> <property name="contentType">html</property>
> <text-property name="content"><![CDATA[Value of my global
> Variable is <VALUE-OF>gblcounter</VALUE-OF>]]></text-property>
> </text>
>
> The value printed out was 0. That means it really didnot change the value
> of the global variable within the dataset.
>
> Thanks
> Chandrika
>
Re: Modify global varaible [message #121832 is a reply to message #121638] Tue, 31 January 2006 12:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

Jason,

Thats how i have right underneath the table.

Chandrika

************************************************************ **

<?xml version="1.0" encoding="UTF-8"?>
<!-- Written by Eclipse BIRT 1.0 -->
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.0.0 Build
&lt;20060123-1141></property>
<property name="units">in</property>
<method name="initialize"><![CDATA[gblcounter = 120;]]></method>
<data-sources>
<oda-data-source
extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source"
id="4">
<property
name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver </property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
name="Data Set" id="5">
<property name="dataSource">Data Source</property>
<method name="onFetch"><![CDATA[gblcounter =
row["ORDERNUMBER"]]]></method>
<property name="queryText">select *
from orders</property>
</oda-data-set>
<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
name="Data Set1" id="57">
<property name="dataSource">Data Source</property>
</oda-data-set>
</data-sets>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new
Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="6">
<property name="width">100%</property>
<property name="dataSet">Data Set</property>
<column id="55"/>
<column id="45"/>
<column id="46"/>
<column id="51"/>
<header>
<row id="7">
<cell id="52"/>
<cell id="8">
<label id="9">
<text-property
name="text">ORDERNUMBER</text-property>
</label>
</cell>
<cell id="10">
<label id="11">
<text-property
name="text">ORDERDATE</text-property>
</label>
</cell>
<cell id="20">
<label id="21">
<text-property
name="text">CUSTOMERNUMBER</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="22">
<cell id="53">
<data id="56">
<expression
name="valueExpr">gblcounter</expression>
</data>
</cell>
<cell id="23">
<data id="24">
<expression
name="valueExpr">row["ORDERNUMBER"]</expression>
</data>
</cell>
<cell id="25">
<data id="26">
<expression
name="valueExpr">row["ORDERDATE"]</expression>
</data>
</cell>
<cell id="35">
<data id="36">
<expression
name="valueExpr">row["CUSTOMERNUMBER"]</expression>
</data>
</cell>
</row>
</detail>
<footer>
<row id="37">
<cell id="54"/>
<cell id="38"/>
<cell id="39"/>
<cell id="44"/>
</row>
</footer>
</table>
<text id="58">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[Value of my global
Variable is <VALUE-OF>gblcounter</VALUE-OF>]]></text-property>
</text>
</body>
</report>

************************************************************ ***************

result:

...............................
..
..
10425 10424 May 31, 2005 12:00 AM 141
10425 10425 May 31, 2005 12:00 AM 119


Value of my global Variable is 0
Jan 31, 2006 9:39 AM
Re: Modify global varaible [message #121860 is a reply to message #121832] Tue, 31 January 2006 10:23 Go to previous messageGo to next message
Eclipse UserFriend
Chandrika,

I put a a dynamic text control beneath the table and and in the expression
builder I put.
"Value of my counter is " + gblcounter.
I dont think you need the Valueof tag.

Jason

"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:7b1725b736ef196875d8f8e361402d9e$1@www.eclipse.org...
> Jason,
>
> Thats how i have right underneath the table.
>
> Chandrika
>
> ************************************************************ **
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Written by Eclipse BIRT 1.0 -->
> <report xmlns="http://www.eclipse.org/birt/2005/design" version="3"
> id="1">
> <property name="createdBy">Eclipse BIRT Designer Version 2.0.0 Build
> &lt;20060123-1141></property>
> <property name="units">in</property>
> <method name="initialize"><![CDATA[gblcounter = 120;]]></method>
> <data-sources>
> <oda-data-source
> extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source"
> id="4">
> <property
> name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver </property>
> <property name="odaURL">jdbc:classicmodels:sampledb</property>
> <property name="odaUser">ClassicModels</property>
> </oda-data-source>
> </data-sources>
> <data-sets>
> <oda-data-set
> extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
> name="Data Set" id="5">
> <property name="dataSource">Data Source</property>
> <method name="onFetch"><![CDATA[gblcounter =
> row["ORDERNUMBER"]]]></method>
> <property name="queryText">select *
> from orders</property>
> </oda-data-set>
> <oda-data-set
> extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
> name="Data Set1" id="57">
> <property name="dataSource">Data Source</property>
> </oda-data-set>
> </data-sets>
> <page-setup>
> <simple-master-page name="Simple MasterPage" id="2">
> <page-footer>
> <text id="3">
> <property name="contentType">html</property>
> <text-property name="content"><![CDATA[<value-of>new
> Date()</value-of>]]></text-property>
> </text>
> </page-footer>
> </simple-master-page>
> </page-setup>
> <body>
> <table id="6">
> <property name="width">100%</property>
> <property name="dataSet">Data Set</property>
> <column id="55"/>
> <column id="45"/>
> <column id="46"/>
> <column id="51"/>
> <header>
> <row id="7">
> <cell id="52"/>
> <cell id="8">
> <label id="9">
> <text-property
> name="text">ORDERNUMBER</text-property>
> </label>
> </cell>
> <cell id="10">
> <label id="11">
> <text-property
> name="text">ORDERDATE</text-property>
> </label>
> </cell>
> <cell id="20">
> <label id="21">
> <text-property
> name="text">CUSTOMERNUMBER</text-property>
> </label>
> </cell>
> </row>
> </header>
> <detail>
> <row id="22">
> <cell id="53">
> <data id="56">
> <expression
> name="valueExpr">gblcounter</expression>
> </data>
> </cell>
> <cell id="23">
> <data id="24">
> <expression
> name="valueExpr">row["ORDERNUMBER"]</expression>
> </data>
> </cell>
> <cell id="25">
> <data id="26">
> <expression
> name="valueExpr">row["ORDERDATE"]</expression>
> </data>
> </cell>
> <cell id="35">
> <data id="36">
> <expression
> name="valueExpr">row["CUSTOMERNUMBER"]</expression>
> </data>
> </cell>
> </row>
> </detail>
> <footer>
> <row id="37">
> <cell id="54"/>
> <cell id="38"/>
> <cell id="39"/>
> <cell id="44"/>
> </row>
> </footer>
> </table>
> <text id="58">
> <property name="contentType">html</property>
> <text-property name="content"><![CDATA[Value of my global
> Variable is <VALUE-OF>gblcounter</VALUE-OF>]]></text-property>
> </text>
> </body>
> </report>
>
> ************************************************************ ***************
>
> result:
>
> ..............................
> .
> .
> 10425 10424 May 31, 2005 12:00 AM 141 10425 10425 May 31, 2005 12:00
> AM 119
> Value of my global Variable is 0 Jan 31, 2006 9:39 AM
Re: Modify global varaible [message #121923 is a reply to message #121860] Tue, 31 January 2006 14:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

Jason,

The example is still not working even with the dynamic text control and
this is after the table.
Am i just missing something? I scenario i have is to set the value of the
global variable in one dataset and use that in another dataset.

<text-data id="59">
<expression name="valueExpr">"Value of my counter is " +
gblcounter</expression>
<property name="contentType">html</property>
</text-data>
</body>


Value of my counter is 0

Thanks
Chandrika
Re: Modify global varaible [message #122060 is a reply to message #121923] Tue, 31 January 2006 13:09 Go to previous messageGo to next message
Eclipse UserFriend
Chandrika,

Here is the same example I sent you earlier but I added a second table that
has
a where clause that uses the gblcounter. Note the default parameter is
changed to gblcounter when I bind it to the second table.

<?xml version="1.0" encoding="UTF-8"?>

<!-- Written by Eclipse BIRT 2.0 -->

<report xmlns="http://www.eclipse.org/birt/2005/design" version="3" id="1">

<property name="createdBy">Eclipse BIRT Designer Version 2.0.0 Build
&lt;20060123-1141></property>

<property name="units">in</property>

<method name="initialize"><![CDATA[gblcounter = 0;]]></method>

<data-sources>

<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc"
name="Data Source" id="4">

<property
name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver </property>

<property name="odaURL">jdbc:classicmodels:sampledb</property>

<property name="odaUser">ClassicModels</property>

</oda-data-source>

</data-sources>

<data-sets>

<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
name="Data Set" id="5">

<property name="dataSource">Data Source</property>

<method name="onFetch"><![CDATA[gblcounter = row["ORDERNUMBER"]]]></method>

<property name="queryText">select *

from orders</property>

</oda-data-set>

<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
name="getcounter" id="60">

<property name="dataSource">Data Source</property>

<list-property name="parameters">

<structure>

<property name="name">ordernumber</property>

<property name="dataType">integer</property>

<property name="position">1</property>

<expression name="defaultValue">10100</expression>

<property name="allowNull">true</property>

<property name="isInput">true</property>

<property name="isOutput">false</property>

</structure>

</list-property>

<property name="queryText">select *

from orderdetails

where CLASSICMODELS.ORDERDETAILS.ORDERNUMBER = ?</property>

</oda-data-set>

</data-sets>

<page-setup>

<simple-master-page name="Simple MasterPage" id="2">

<page-footer>

<text id="3">

<property name="contentType">html</property>

<text-property name="content"><![CDATA[<value-of>new
Date()</value-of>]]></text-property>

</text>

</page-footer>

</simple-master-page>

</page-setup>

<body>

<table id="6">

<property name="width">100%</property>

<property name="dataSet">Data Set</property>

<column id="55"/>

<column id="45"/>

<column id="46"/>

<column id="51"/>

<header>

<row id="7">

<cell id="52"/>

<cell id="8">

<label id="9">

<text-property name="text">ORDERNUMBER</text-property>

</label>

</cell>

<cell id="10">

<label id="11">

<text-property name="text">ORDERDATE</text-property>

</label>

</cell>

<cell id="20">

<label id="21">

<text-property name="text">CUSTOMERNUMBER</text-property>

</label>

</cell>

</row>

</header>

<detail>

<row id="22">

<cell id="53">

<data id="56">

<expression name="valueExpr">gblcounter</expression>

</data>

</cell>

<cell id="23">

<data id="24">

<expression name="valueExpr">row["ORDERNUMBER"]</expression>

</data>

</cell>

<cell id="25">

<data id="26">

<expression name="valueExpr">row["ORDERDATE"]</expression>

</data>

</cell>

<cell id="35">

<data id="36">

<expression name="valueExpr">row["CUSTOMERNUMBER"]</expression>

</data>

</cell>

</row>

</detail>

<footer>

<row id="37">

<cell id="54"/>

<cell id="38"/>

<cell id="39"/>

<cell id="44"/>

</row>

</footer>

</table>

<text-data id="58">

<expression name="valueExpr">gblcounter</expression>

<property name="contentType">html</property>

</text-data>

<text-data id="59">

<expression name="valueExpr">"Value of my counter is "+
gblcounter</expression>

<property name="contentType">html</property>

</text-data>

<table id="61">

<property name="width">100%</property>

<property name="dataSet">getcounter</property>

<list-property name="paramBindings">

<structure>

<property name="paramName">ordernumber</property>

<expression name="expression">gblcounter</expression>

</structure>

</list-property>

<column id="90"/>

<column id="91"/>

<header>

<row id="62">

<cell id="63">

<label id="64">

<text-property name="text">ORDERNUMBER Should be based on
gblcounter</text-property>

</label>

</cell>

<cell id="65">

<label id="66">

<text-property name="text">PRODUCTCODE</text-property>

</label>

</cell>

</row>

</header>

<detail>

<row id="73">

<cell id="74">

<data id="75">

<expression name="valueExpr">row["ORDERNUMBER"]</expression>

</data>

</cell>

<cell id="76">

<data id="77">

<expression name="valueExpr">row["PRODUCTCODE"]</expression>

</data>

</cell>

</row>

</detail>

<footer>

<row id="84">

<cell id="85"/>

<cell id="86"/>

</row>

</footer>

</table>

</body>

</report>



Jason

"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:e15b44ccb4bc62fa13de61d133443ead$1@www.eclipse.org...
> Jason,
>
> The example is still not working even with the dynamic text control and
> this is after the table.
> Am i just missing something? I scenario i have is to set the value of the
> global variable in one dataset and use that in another dataset.
> <text-data id="59">
> <expression name="valueExpr">"Value of my counter is " +
> gblcounter</expression>
> <property name="contentType">html</property>
> </text-data>
> </body>
>
>
> Value of my counter is 0
> Thanks
> Chandrika
>
Re: Modify global varaible [message #122460 is a reply to message #122060] Wed, 01 February 2006 02:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

Hi Jason,


Last few lines of the result from your example:

*************************************
10425 10424 May 31, 2005 12:00 AM 141
10425 10425 May 31, 2005 12:00 AM 119


0.0
Value of my counter is 0
ORDERNUMBER Should be based on
gblcounter PRODUCTCODE


Jan 31, 2006 11:27 PM

***********************************
The second table doesnot have any rows, does that mean the global variable
value is 0?

Thanks
Chandrika
Re: Modify global varaible [message #122750 is a reply to message #122460] Wed, 01 February 2006 07:41 Go to previous messageGo to next message
Eclipse UserFriend
Chandrika

This is what I am getting when I run this example

10425 10424 May 31, 2005 12:00 AM 141
10425 10425 May 31, 2005 12:00 AM 119


10425
Value of my counter is 10425
ORDERNUMBER Should be based on gblcounter PRODUCTCODE
10425 S10_4962
10425 S12_4473

What version of BIRT are you using?

Jason


"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:1c7f176fb042f7f0b03012120b2e95e3$1@www.eclipse.org...
> Hi Jason,
>
>
> Last few lines of the result from your example:
>
> *************************************
> 10425 10424 May 31, 2005 12:00 AM 141 10425 10425 May 31, 2005 12:00
> AM 119
> 0.0 Value of my counter is 0 ORDERNUMBER Should be based on
> gblcounter PRODUCTCODE
> Jan 31, 2006 11:27 PM
> ***********************************
> The second table doesnot have any rows, does that mean the global variable
> value is 0?
>
> Thanks
> Chandrika
>
>
Re: Modify global varaible [message #122805 is a reply to message #122750] Wed, 01 February 2006 12:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

Iam using the Birt2.0RC version

Chandrika
Re: Modify global varaible [message #122815 is a reply to message #122805] Wed, 01 February 2006 10:17 Go to previous messageGo to next message
Eclipse UserFriend
Can you try 2.0 final?

Jason

"chandrika" <cchopra@executivehealthexams.com> wrote in message
news:a8851615ba164b030e722f2db75fb098$1@www.eclipse.org...
> Iam using the Birt2.0RC version
>
> Chandrika
>
Re: Modify global varaible [message #123260 is a reply to message #122815] Thu, 02 February 2006 13:56 Go to previous message
Eclipse UserFriend
Originally posted by: cchopra.executivehealthexams.com

Looks like it was a bug in the birt 2.0 RC. Finally got it to work with
the 2.0 final release. :)
Thanks a lot Jason

Chandrika
Previous Topic:Blank Page
Next Topic:How to add a Page Breaks in a Report?
Goto Forum:
  


Current Time: Tue May 06 02:17:43 EDT 2025

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

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

Back to the top