|
(no subject) [message #683486 is a reply to message #683451] |
Mon, 13 June 2011 20:45 |
|
Robert
try:
reportContext.getPageVariable("V_REP_VAR");
to access the report level variables. global and globalpersistent
variables are a way to store variables for access in script and
expressions. persistent means it will write the value to a rptdocument
to store the value across phases (run then render). Report Variables
can be used in similar fashion but were primarily designed to be used in
autotext elements on the master page (eg page n of m).
Jason
On 6/13/2011 3:10 PM, Robert Aust wrote:
>
> Hello,
>
> I'm am a bit confused about the correct usage of variables and their
> scopes.
> I defined a variable V_REP_VAR as "Report Variable" in the outline on
> designer with a default-value of '<default>'.
>
> When I use this variable in javascript expression builder it is
> automatically inserted as "vars['V_REP_VAR']" which correctly gives me
> the default-value.
>
> But using the reportContext-methods does not deliver the value.
> Is there a connection between the 'vars[..]'-Array and the
> reportContext-methods 'getGlobalVariable(..)' and
> 'getGlobalPersistentVariable(..)' ?
>
> I have some EventHandlers in Java in my report, that need this variable,
> but cannot access 'vars[..]' obviously.
>
> Here's my sample :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22"
> id="1">
> <property name="createdBy">Eclipse BIRT Designer Version
> 2.6.2.r262_v20110209 Build <2.6.2.v20110214-1523></property>
> <property name="units">in</property>
> <property name="iconFile">/templates/blank_report.gif</property>
> <property name="bidiLayoutOrientation">ltr</property>
> <property name="imageDPI">96</property>
> <data-sources>
> <oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc"
> name="DS_SAMPLE" id="7">
> <list-property name="privateDriverProperties">
> <ex-property>
> <name>contentBidiFormatStr</name>
> <value>ILYNN</value>
> </ex-property>
> <ex-property>
> <name>metadataBidiFormatStr</name>
> <value>ILYNN</value>
> </ex-property>
> </list-property>
> <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>
> <styles>
> <style name="report" id="4">
> <property name="fontFamily">sans-serif</property>
> <property name="fontSize">10pt</property>
> </style>
> <style name="crosstab-cell" id="5">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> <style name="crosstab" id="6">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> </styles>
> <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>
> <grid id="10">
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">Column Binding</property>
> <expression name="expression"
> type="javascript">'...getGlobalVariable=['+reportContext.getGlobalVariable('V_REP_VAR')+']';</expression>
>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="name">CB2</property>
> <expression name="expression"
> type="javascript">'...PersistentGlobalVariable=['+reportContext.getPersistentGlobalVariable('V_REP_VAR')+']';</expression>
>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <column id="11"/>
> <column id="12"/>
> <column id="13"/>
> <row id="14">
> <cell id="15"/>
> <cell id="16"/>
> <cell id="17"/>
> </row>
> <row id="18">
> <cell id="19">
> <text-data id="29">
> <expression name="valueExpr">'...vars=['+vars["V_REP_VAR"]+']'</expression>
> <property name="contentType">plain</property>
> </text-data>
> </cell>
> <cell id="20">
> <data id="27">
> <property name="resultSetColumn">Column Binding</property>
> </data>
> </cell>
> <cell id="21">
> <data id="28">
> <property name="resultSetColumn">CB2</property>
> </data>
> </cell>
> </row>
> <row id="33">
> <method name="onCreate"><![CDATA[vars['V_REP_VAR'] = '<newValue>'
> reportContext.setGlobalVariable('V_REP_VAR', '<anotherValue>');
> reportContext.setPersistentGlobalVariable('V_REP_VAR',
> '<anotherPersistentValue>');]]></method>
> <cell id="34">
> <text-data id="37">
> <expression name="valueExpr">'...vars=['+vars["V_REP_VAR"]+']'</expression>
> <property name="contentType">plain</property>
> </text-data>
> </cell>
> <cell id="35">
> <text-data id="40">
> <expression
> name="valueExpr">'...getGlobalVariable['+reportContext.getGlobalVariable('V_REP_VAR')+']'</expression>
>
> <property name="contentType">plain</property>
> </text-data>
> </cell>
> <cell id="36">
> <text-data id="41">
> <expression
> name="valueExpr">'...getPersistentGlobalVariable['+reportContext.getPersistentGlobalVariable('V_REP_VAR')+']'</expression>
>
> <property name="contentType">plain</property>
> </text-data>
> </cell>
> </row>
> </grid>
> </body>
> <property name="pageVariables">
> <variable-element name="V_REP_VAR">
> <expression name="value" type="javascript">'<default>'</expression>
> <property name="type">report</property>
> </variable-element>
> </property>
> </report>
>
> Thanks for any help!
> Robert
>
|
|
|
(no subject) [message #683877 is a reply to message #683486] |
Tue, 14 June 2011 15:17 |
Robert Aust Messages: 17 Registered: July 2009 |
Junior Member |
|
|
Hi Jason,
that worked, Thanks!
I didn't think of trying 'getPageVariable'...was looking for something
more 'global'.
Robert
Am 13.06.2011 22:45, schrieb Jason Weathersby:
> Robert
>
> try:
> reportContext.getPageVariable("V_REP_VAR");
>
> to access the report level variables. global and globalpersistent
> variables are a way to store variables for access in script and
> expressions. persistent means it will write the value to a rptdocument
> to store the value across phases (run then render). Report Variables can
> be used in similar fashion but were primarily designed to be used in
> autotext elements on the master page (eg page n of m).
>
> Jason
>
> On 6/13/2011 3:10 PM, Robert Aust wrote:
>>
>> Hello,
>>
>> I'm am a bit confused about the correct usage of variables and their
>> scopes.
>> I defined a variable V_REP_VAR as "Report Variable" in the outline on
>> designer with a default-value of '<default>'.
>>
>> When I use this variable in javascript expression builder it is
>> automatically inserted as "vars['V_REP_VAR']" which correctly gives me
>> the default-value.
>>
>> But using the reportContext-methods does not deliver the value.
>> Is there a connection between the 'vars[..]'-Array and the
>> reportContext-methods 'getGlobalVariable(..)' and
>> 'getGlobalPersistentVariable(..)' ?
>>
>> I have some EventHandlers in Java in my report, that need this variable,
>> but cannot access 'vars[..]' obviously.
>>
>> Here's my sample :
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22"
>> id="1">
>> <property name="createdBy">Eclipse BIRT Designer Version
>> 2.6.2.r262_v20110209 Build <2.6.2.v20110214-1523></property>
>> <property name="units">in</property>
>> <property name="iconFile">/templates/blank_report.gif</property>
>> <property name="bidiLayoutOrientation">ltr</property>
>> <property name="imageDPI">96</property>
>> <data-sources>
>> <oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc"
>> name="DS_SAMPLE" id="7">
>> <list-property name="privateDriverProperties">
>> <ex-property>
>> <name>contentBidiFormatStr</name>
>> <value>ILYNN</value>
>> </ex-property>
>> <ex-property>
>> <name>metadataBidiFormatStr</name>
>> <value>ILYNN</value>
>> </ex-property>
>> </list-property>
>> <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>
>> <styles>
>> <style name="report" id="4">
>> <property name="fontFamily">sans-serif</property>
>> <property name="fontSize">10pt</property>
>> </style>
>> <style name="crosstab-cell" id="5">
>> <property name="borderBottomColor">#CCCCCC</property>
>> <property name="borderBottomStyle">solid</property>
>> <property name="borderBottomWidth">1pt</property>
>> <property name="borderLeftColor">#CCCCCC</property>
>> <property name="borderLeftStyle">solid</property>
>> <property name="borderLeftWidth">1pt</property>
>> <property name="borderRightColor">#CCCCCC</property>
>> <property name="borderRightStyle">solid</property>
>> <property name="borderRightWidth">1pt</property>
>> <property name="borderTopColor">#CCCCCC</property>
>> <property name="borderTopStyle">solid</property>
>> <property name="borderTopWidth">1pt</property>
>> </style>
>> <style name="crosstab" id="6">
>> <property name="borderBottomColor">#CCCCCC</property>
>> <property name="borderBottomStyle">solid</property>
>> <property name="borderBottomWidth">1pt</property>
>> <property name="borderLeftColor">#CCCCCC</property>
>> <property name="borderLeftStyle">solid</property>
>> <property name="borderLeftWidth">1pt</property>
>> <property name="borderRightColor">#CCCCCC</property>
>> <property name="borderRightStyle">solid</property>
>> <property name="borderRightWidth">1pt</property>
>> <property name="borderTopColor">#CCCCCC</property>
>> <property name="borderTopStyle">solid</property>
>> <property name="borderTopWidth">1pt</property>
>> </style>
>> </styles>
>> <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>
>> <grid id="10">
>> <list-property name="boundDataColumns">
>> <structure>
>> <property name="name">Column Binding</property>
>> <expression name="expression"
>> type="javascript">'...getGlobalVariable=['+reportContext.getGlobalVariable('V_REP_VAR')+']';</expression>
>>
>>
>> <property name="dataType">string</property>
>> </structure>
>> <structure>
>> <property name="name">CB2</property>
>> <expression name="expression"
>> type="javascript">'...PersistentGlobalVariable=['+reportContext.getPersistentGlobalVariable('V_REP_VAR')+']';</expression>
>>
>>
>> <property name="dataType">string</property>
>> </structure>
>> </list-property>
>> <column id="11"/>
>> <column id="12"/>
>> <column id="13"/>
>> <row id="14">
>> <cell id="15"/>
>> <cell id="16"/>
>> <cell id="17"/>
>> </row>
>> <row id="18">
>> <cell id="19">
>> <text-data id="29">
>> <expression
>> name="valueExpr">'...vars=['+vars["V_REP_VAR"]+']'</expression>
>> <property name="contentType">plain</property>
>> </text-data>
>> </cell>
>> <cell id="20">
>> <data id="27">
>> <property name="resultSetColumn">Column Binding</property>
>> </data>
>> </cell>
>> <cell id="21">
>> <data id="28">
>> <property name="resultSetColumn">CB2</property>
>> </data>
>> </cell>
>> </row>
>> <row id="33">
>> <method name="onCreate"><![CDATA[vars['V_REP_VAR'] = '<newValue>'
>> reportContext.setGlobalVariable('V_REP_VAR', '<anotherValue>');
>> reportContext.setPersistentGlobalVariable('V_REP_VAR',
>> '<anotherPersistentValue>');]]></method>
>> <cell id="34">
>> <text-data id="37">
>> <expression
>> name="valueExpr">'...vars=['+vars["V_REP_VAR"]+']'</expression>
>> <property name="contentType">plain</property>
>> </text-data>
>> </cell>
>> <cell id="35">
>> <text-data id="40">
>> <expression
>> name="valueExpr">'...getGlobalVariable['+reportContext.getGlobalVariable('V_REP_VAR')+']'</expression>
>>
>>
>> <property name="contentType">plain</property>
>> </text-data>
>> </cell>
>> <cell id="36">
>> <text-data id="41">
>> <expression
>> name="valueExpr">'...getPersistentGlobalVariable['+reportContext.getPersistentGlobalVariable('V_REP_VAR')+']'</expression>
>>
>>
>> <property name="contentType">plain</property>
>> </text-data>
>> </cell>
>> </row>
>> </grid>
>> </body>
>> <property name="pageVariables">
>> <variable-element name="V_REP_VAR">
>> <expression name="value" type="javascript">'<default>'</expression>
>> <property name="type">report</property>
>> </variable-element>
>> </property>
>> </report>
>>
>> Thanks for any help!
>> Robert
>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03050 seconds