BIRT Exchange Forum: Use of session's varibles in BIRT - BIRT Exchange Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Use of session's varibles in BIRT Rate Topic: -----

#1 User is offline   cheli 

  • Junior Member
  • PipPip
  • Group: Members
  • Posts: 25
  • Joined: 11-March 10

Posted 16 May 2010 - 11:37 PM

hi everyone,

I have one small site web in PHP that allow users authenticate and give them access to the reports. I want to increase the security and for that i create a key in the site web that it's unique for any user and i put it in a cookie for it is possible to access it in BIRT.

In the BIRT's report i have this code in the beforeFactory script:

importPackage( Packages.javax.servlet.http );

var request = reportContext.getHttpServletRequest();
var cookies = request.getCookies();
var cookiestring="";
var tm = new Date();
hour = tm.getUTCHours().toString();
prev_hour = (tm.getUTCHours()-1).toString();

//if the hour is one digit, we need to add a leading 0 because this is also used in PHP
if (hour.length==1) {hour='0'+hour};
if (prev_hour.length==1) {prev_hour='0'+prev_hour};


//search for the correct cookie, being OUR_REPORT
for (i=0; i< cookies.length; i++)
{
if(cookies[i].getName().equals("OUR_REPORT")){
cookiestring=cookies[i].getValue();
}
}

//read the url values
var request = reportContext.getHttpServletRequest();
user=request.getParameter("user");
repname=request.getParameter("__report");
urlstring=(String)(repname+user+hour);
prev_urlstring=(String)(repname+user+prev_hour);


//set the flag to allow the report components to hide if flag=1 (= no access)
if (cookiestring!=urlstring)
{
if (cookiestring!=prev_urlstring) {flag=1;}
reportContext.setGlobalVariable('access_flag', flag);
}

this script compare the key that i put in the site web with the same key but in this moment it is generated in the BIRT's script, if they are differents on put the global variable flag = 1. Here is my problem. I don't know how to use the globla variables. In this case i generated access_flag variable in the data explorer variables and the variable flag in the initialize script and then i use the access flag variables for the visibility conditions of the report's elements.
This don't go , what is the problem?

PD: sorry about my english, i'm not so good in English
0

#2 User is offline   averma 

  • Senior Member
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 298
  • Joined: 08-August 07

Posted 29 July 2010 - 09:57 AM

Hi cheli,
I would recommend using reportContext.setPersistentGlobalVariable() and reportContext.getPersistentGlobalVariable() methods. This allows variables to be persisted across generation and presentation (rendering).

Ashwini
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users