|
|
|
Re: var OR dynamic data set OR?? [message #827746 is a reply to message #827131] |
Fri, 23 March 2012 18:47 |
|
The fetch method is only called once per data set row. Generally you
set up an iterator in the open and use the iterator in the fetch. In
your case is userParams one row of data or multiple rows?
Jason
On 3/22/2012 7:35 PM, Kris Tannar wrote:
> Hi,
> I am very new to BIRT and not sure how best to tackle what I need to do.
> I need to take values entered in client and pass them to the server and
> subsequently the BIRT report.
>
> I'm using a POJO:
> public List<ReportRecord> getReportValues(String reportStartTime, String
> reportEndTime)
>
> {
> List<ReportRecord> record = new ArrayList<ReportRecord>();
> for (int i = 0; i < record.size(); i++)
> {
> ReportRecord reportRecord = new ReportRecord();
> reportRecord.setReportStartTime(reportStartTime);
> reportRecord.setReportEndTime(reportEndTime);
> record.add(reportRecord);
> }
> return record;
> }
>
> My open script:
> importPackage(Packages.com.reports.server);
> count = 0;
>
>
> // Create instance of
> // the class
>
> reportParams = new Packages.com.reports.server.ReportServiceImpl();
> //Load the List
>
> userParams = reportParams.getReportValues("Java", "Java");
> My fetch:
> if (count < userParams.size() )
> {
> var rtnString = userParams.get(count).getReportStart();
> dataSetRow["Start Time:"] = rtnString;
> var rtnStrng = userParams.get(count).getReportEndTime
> dataSetRow["End Time:"] = rtnString; count++;
>
> return true;
> }
> return false;
>
> My values make it to the server (tomcat) fine. However, the default
> value "Java" show up for both variable. Just to mention this, I am using
> two different data sets for the same report.
>
> What am I missing?
|
|
|
Re: var OR dynamic data set OR?? [message #827754 is a reply to message #827622] |
Fri, 23 March 2012 18:56 |
|
Move this to the open:
userParams = reportParams.getReportValues("Java");
Then in the fetch use:
if (count < userParams.size() )
{
var rowdata = userParams.get(count);
importPackage( Packages.java.io );
out = new PrintWriter( new FileWriter( "c:/temp/fetchevents.txt", true ) );
out.println( "row data " + rowdata);
out.println( "firstCol " + rowdata.getReportStart());
out.close();
var rtnString = rowdata.getReportStart();
dataSetRow["Start Time:"] = rtnString;
var rtnStrng = rowdata.getReportEndTime
dataSetRow["End Time:"] = rtnString;
count++;
return true;
}
return false;
Then take a look at the text file that is generated.
Jason
On 3/23/2012 11:26 AM, Kris Tannar wrote:
> After a little more reading, I'm using the beforeOpen script for my var:
>
> importPackage(Packages.com.reports.server);
> count = 0;
>
>
> // Create instance of
> // the class
>
> reportParams = new Packages.com.reports.server.ReportServiceImpl();
> //Load the List
>
> userParams = reportParams.getReportValues("Java");
> if (count < userParams.size() )
> {
> var rtnString = userParams.get(count).getReportStart();
> dataSetRow["Start Time:"] = rtnString;
>
> var rtnStrng = userParams.get(count).getReportEndTime
> dataSetRow["End Time:"] = rtnString;
> count++;
>
> return true;
> }
> return false;
>
>
> However, the var data is still not being passed to the report.
> Any ideas?
> Thanks!
|
|
|
|
|
Re: var OR dynamic data set OR?? [message #830743 is a reply to message #829616] |
Wed, 28 March 2012 02:26 |
|
What do you get when you change:
userParams = reportParams.getReportValues("Java");
to
userParams = reportParams.getReportValues("Java", "Java", "Java");
Jason
On 3/26/2012 10:57 AM, Kris Tannar wrote:
> Hi Jason,
> Went through another iteration making the changes you suggested; please
> see the open and fetch scripts below:
>
> open:
> importPackage(Packages.com.reports.server);
> count = 0;
>
> // Create instance of
> // Service class
>
> reportParams = new Packages.com.reports.server.ReportServiceImpl();
> //Load the List
>
> userParams = reportParams.getReportValues("Java");
>
>
> fetch:
> if (count < userParams.size() )
> {
> var rowdata = userParams.get(count);
>
> importPackage( Packages.java.io );
> out = new PrintWriter( new FileWriter( "c:/temp/Newfetchevents.txt",
> true ) );
> out.println( "row data " + rowdata);
> out.println( "firstCol " + rowdata.getEndUser());
> out.println( "secondCol " + rowdata.getReportStartTime());
> out.println( "ThirdCol " + rowdata.getReportEndTime());
> out.close();
>
> var rtnString = rowdata.getEndUser();
> dataSetRow["End User:"] = rtnString;
>
> var rtnString = rowdata.getReportStartTime();
> dataSetRow["Start Time:"] = rtnString;
>
> var rtnString = rowdata.getReportEndTime();
> dataSetRow["End Time:"] = rtnString;
>
> count++;
>
> return true;
> }
> return false;
>
> However, I receive a BIRT error:
> "Can't find method
> com.reports.server.ReportServiceImpl.getReportValues(string)" from the
> open script.
> This is understandable because the method signature in the script does
> not match the getReportValues(string, string string) signature.
>
> Can't seem to build my scripts properly to retrieve data from the user,
> place it into the report design at run time. What am I missing?
> Any help would be super appreciated!!
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03564 seconds