|
Re: parameter.displayText in RE [message #502546 is a reply to message #502467] |
Tue, 08 December 2009 18:40 |
|
Jarda,
you should be able to use:
reportContext.getParameterDisplayText("ParmName")
in an expression. How are you attempting it now?
Jason
Jaroslav Uher wrote:
> I have parametrized report generated by report engine (using
> genreport.bat). I use displayText of parameter to build variable report
> titles and descriptions. It works good in design mode or viewer.
>
> In RE i get only "null" from getParameterDisplayText().
>
> I found only an solution for servlet report, what is useless fro me. Is
> it possible to add similar code to rptdesign? I need both viewer and RE
> form of deploying of report.
>
> Thanks for a hint
> Jarda
|
|
|
|
Re: parameter.displayText in RE [message #502743 is a reply to message #502628] |
Wed, 09 December 2009 15:28 |
|
Jarda,
You are correct it will not work with the report runner class that is
called in that bat file. The reason it works with the viewer and not
the report runner, is that the viewer sets it after the user selects a
value for the parameter. The reportrunner class does not do this. You
could modify the reportrunner class or write your own and use code like
this:
task.setParameterValue("parm1", "value2");
task.setParameterDisplayText("parm1", "testme");
If you want the display text from the design you can use a parameter
task before you run the report like this:
IGetParameterDefinitionTask ptask =
engine.createGetParameterDefinitionTask( design );
Collection selectionList = ptask.getSelectionList("parm1");
String myDisplayText = "";
if ( selectionList != null )
{
for ( Iterator sliter = selectionList.iterator( ); sliter.hasNext( ); )
{
IParameterSelectionChoice selectionItem = (IParameterSelectionChoice)
sliter.next( );
String lbl = selectionItem.getLabel();
String value = (String)selectionItem.getValue( );
if( value.compareTo("value2") == 0 ){
myDisplayText = selectionItem.getLabel();
break;
}
}
}
ptask.close();
You could then use task.setParameterDisplayText as above with the
variable myDisplayText.
Jason
Jaroslav Uher wrote:
> Hi Jason,
> it works only in viewer or Eclipse IDE. My problem is output from RE,
> command line is:
>
> start "test_par" /WAIT %RE_HOME%\ReportEngine\genreport.bat -f PDF -p
> "par=B" -o \\server\path\test_par.pdf -l cs %RE_HOME%\test_par.rptdesign
>
> Report display only parameter value (B), not associated display text.
>
> Jarda
>
>
> Jason Weathersby napsal(a):
>> Jarda,
>>
>> you should be able to use:
>> reportContext.getParameterDisplayText("ParmName")
>> in an expression. How are you attempting it now?
>>
>> Jason
>>
>> Jaroslav Uher wrote:
>>> I have parametrized report generated by report engine (using
>>> genreport.bat). I use displayText of parameter to build variable
>>> report titles and descriptions. It works good in design mode or viewer.
>>>
>>> In RE i get only "null" from getParameterDisplayText().
>>>
>>> I found only an solution for servlet report, what is useless fro me.
>>> Is it possible to add similar code to rptdesign? I need both viewer
>>> and RE form of deploying of report.
>>>
>>> Thanks for a hint
>>> Jarda
|
|
|
Re: parameter.displayText in RE [message #502992 is a reply to message #502743] |
Thu, 10 December 2009 14:34 |
Jaroslav Uher Messages: 17 Registered: July 2009 |
Junior Member |
|
|
Jason,
thanks for your explanation.
However, I haven´t experience to add described class modification to
reportrunner.
Please, is there way to access SelectionList of a parameter from
JavaScript (directly in particular report through reportContext)? I want
check supplied parameters and modify displayText - like your code below.
Thanks
Jarda
BTW, I am still confused from different report processing on
viewer/reportrunner.
Jason Weathersby napsal(a):
> Jarda,
>
> You are correct it will not work with the report runner class that is
> called in that bat file. The reason it works with the viewer and not
> the report runner, is that the viewer sets it after the user selects a
> value for the parameter. The reportrunner class does not do this. You
> could modify the reportrunner class or write your own and use code like
> this:
>
> task.setParameterValue("parm1", "value2");
> task.setParameterDisplayText("parm1", "testme");
>
> If you want the display text from the design you can use a parameter
> task before you run the report like this:
>
> IGetParameterDefinitionTask ptask =
> engine.createGetParameterDefinitionTask( design );
>
> Collection selectionList = ptask.getSelectionList("parm1");
> String myDisplayText = "";
> if ( selectionList != null )
> {
> for ( Iterator sliter = selectionList.iterator( ); sliter.hasNext( ); )
> {
> IParameterSelectionChoice selectionItem =
> (IParameterSelectionChoice) sliter.next( );
> String lbl = selectionItem.getLabel();
> String value = (String)selectionItem.getValue( );
>
> if( value.compareTo("value2") == 0 ){
> myDisplayText = selectionItem.getLabel();
> break;
> }
>
> }
>
> }
>
> ptask.close();
>
> You could then use task.setParameterDisplayText as above with the
> variable myDisplayText.
>
> Jason
>
> Jaroslav Uher wrote:
>> Hi Jason,
>> it works only in viewer or Eclipse IDE. My problem is output from RE,
>> command line is:
>>
>> start "test_par" /WAIT %RE_HOME%\ReportEngine\genreport.bat -f PDF -p
>> "par=B" -o \\server\path\test_par.pdf -l cs %RE_HOME%\test_par.rptdesign
>>
>> Report display only parameter value (B), not associated display text.
>>
>> Jarda
>>
>>
>> Jason Weathersby napsal(a):
>>> Jarda,
>>>
>>> you should be able to use:
>>> reportContext.getParameterDisplayText("ParmName")
>>> in an expression. How are you attempting it now?
>>>
>>> Jason
>>>
>>> Jaroslav Uher wrote:
>>>> I have parametrized report generated by report engine (using
>>>> genreport.bat). I use displayText of parameter to build variable
>>>> report titles and descriptions. It works good in design mode or viewer.
>>>>
>>>> In RE i get only "null" from getParameterDisplayText().
>>>>
>>>> I found only an solution for servlet report, what is useless fro me.
>>>> Is it possible to add similar code to rptdesign? I need both viewer
>>>> and RE form of deploying of report.
>>>>
>>>> Thanks for a hint
>>>> Jarda
|
|
|
Re: parameter.displayText in RE [message #503056 is a reply to message #502992] |
Thu, 10 December 2009 12:42 |
|
Jarda,
Can you try something like this:
beforeFactory script:
var myDisplayText = "did not find";
importPackage(Packages.org.eclipse.birt.report.engine.api);
var re = reportContext.getReportRunnable().getReportEngine();
var ptask = re.createGetParameterDefinitionTask(
reportContext.getReportRunnable() );
var selectionList = ptask.getSelectionList("parm1");
var myDisplayText = "";
if ( selectionList != null )
{
for ( sliter = selectionList.iterator( ); sliter.hasNext( ); )
{
selectionItem = sliter.next( );
pvalue = selectionItem.getValue();
if( pvalue.compareTo(params["parm1"].value) == 0 ){
myDisplayText = selectionItem.getLabel();
break;
}
}
}
ptask.close();
reportContext.setGlobalVariable("gMyDisplayText", myDisplayText);
then when you want to reference it do this in the expression:
reportContext.getGlobalVariable("gMyDisplayText");
See attached example:
Jason
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.20"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.5.1.v20090903 Build <2.5.1.v20090917-1447></property>
<property name="units">in</property>
<method name="beforeFactory"><![CDATA[var myDisplayText = "did not
find";
importPackage(Packages.org.eclipse.birt.report.engine.api);
var re = reportContext.getReportRunnable().getReportEngine();
var ptask = re.createGetParameterDefinitionTask(
reportContext.getReportRunnable() );
var selectionList = ptask.getSelectionList("parm1");
var myDisplayText = "";
if ( selectionList != null )
{
for ( sliter = selectionList.iterator( ); sliter.hasNext( ); )
{
selectionItem = sliter.next( );
pvalue = selectionItem.getValue();
if( pvalue.compareTo(params["parm1"].value) == 0 ){
myDisplayText = selectionItem.getLabel();
break;
}
}
}
ptask.close();
reportContext.setGlobalVariable("gMyDisplayText",
myDisplayText);]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<parameters>
<scalar-parameter name="parm1" id="7">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="distinct">true</property>
<simple-property-list name="defaultValue">
<value type="constant">value1</value>
</simple-property-list>
<list-property name="selectionList">
<structure>
<property name="value">value1</property>
<property name="label">displayText1</property>
</structure>
<structure>
<property name="value">value2</property>
<property name="label">displayText2</property>
</structure>
<structure>
<property name="value">value3</property>
<property name="label">displayText3</property>
</structure>
</list-property>
<property name="paramType">simple</property>
<property name="controlType">list-box</property>
<property name="mustMatch">true</property>
<property name="fixedOrder">true</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</parameters>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab" 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-cell" 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>
<data id="8">
<list-property name="boundDataColumns">
<structure>
<property name="name">parm1</property>
<expression
name="expression">params["parm1"].value</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="resultSetColumn">parm1</property>
</data>
<data id="9">
<list-property name="boundDataColumns">
<structure>
<property name="name">Column Binding</property>
<expression name="expression"
type="javascript">reportContext.getGlobalVariable("gMyDisplayText ");</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="resultSetColumn">Column Binding</property>
</data>
</body>
</report>
Jaroslav Uher wrote:
> Jason,
> thanks for your explanation.
>
> However, I haven´t experience to add described class modification to
> reportrunner.
>
> Please, is there way to access SelectionList of a parameter from
> JavaScript (directly in particular report through reportContext)? I want
> check supplied parameters and modify displayText - like your code below.
>
> Thanks
> Jarda
>
> BTW, I am still confused from different report processing on
> viewer/reportrunner.
>
>
> Jason Weathersby napsal(a):
>> Jarda,
>>
>> You are correct it will not work with the report runner class that is
>> called in that bat file. The reason it works with the viewer and not
>> the report runner, is that the viewer sets it after the user selects a
>> value for the parameter. The reportrunner class does not do this.
>> You could modify the reportrunner class or write your own and use code
>> like this:
>>
>> task.setParameterValue("parm1", "value2");
>> task.setParameterDisplayText("parm1", "testme");
>>
>> If you want the display text from the design you can use a parameter
>> task before you run the report like this:
>>
>> IGetParameterDefinitionTask ptask =
>> engine.createGetParameterDefinitionTask( design );
>> Collection selectionList = ptask.getSelectionList("parm1");
>> String myDisplayText = "";
>> if ( selectionList != null )
>> {
>> for ( Iterator sliter = selectionList.iterator( ); sliter.hasNext(
>> ); )
>> {
>> IParameterSelectionChoice selectionItem =
>> (IParameterSelectionChoice) sliter.next( );
>> String lbl = selectionItem.getLabel();
>> String value = (String)selectionItem.getValue( );
>> if( value.compareTo("value2") == 0 ){
>> myDisplayText = selectionItem.getLabel();
>> break;
>> }
>>
>> }
>> } ptask.close();
>>
>> You could then use task.setParameterDisplayText as above with the
>> variable myDisplayText.
>>
>> Jason
>>
>> Jaroslav Uher wrote:
>>> Hi Jason,
>>> it works only in viewer or Eclipse IDE. My problem is output from RE,
>>> command line is:
>>>
>>> start "test_par" /WAIT %RE_HOME%\ReportEngine\genreport.bat -f PDF -p
>>> "par=B" -o \\server\path\test_par.pdf -l cs %RE_HOME%\test_par.rptdesign
>>>
>>> Report display only parameter value (B), not associated display text.
>>>
>>> Jarda
>>>
>>>
>>> Jason Weathersby napsal(a):
>>>> Jarda,
>>>>
>>>> you should be able to use:
>>>> reportContext.getParameterDisplayText("ParmName")
>>>> in an expression. How are you attempting it now?
>>>>
>>>> Jason
>>>>
>>>> Jaroslav Uher wrote:
>>>>> I have parametrized report generated by report engine (using
>>>>> genreport.bat). I use displayText of parameter to build variable
>>>>> report titles and descriptions. It works good in design mode or
>>>>> viewer.
>>>>>
>>>>> In RE i get only "null" from getParameterDisplayText().
>>>>>
>>>>> I found only an solution for servlet report, what is useless fro
>>>>> me. Is it possible to add similar code to rptdesign? I need both
>>>>> viewer and RE form of deploying of report.
>>>>>
>>>>> Thanks for a hint
>>>>> Jarda
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04192 seconds