Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Adding an object to the application context! (Book example: Integrating and Extending)(I can't get the application context in my report!)
Adding an object to the application context! (Book example: Integrating and Extending) [message #991469] Wed, 19 December 2012 11:20 Go to next message
Samo B. is currently offline Samo B.
Messages: 41
Registered: December 2012
Member
Hi all,

I'm new at BIRT and trying to work into it. I'm using the book "Integrating and Extending BIRT".
In the initial situation is that I have a jsp file like this:
<%
	java.lang.String teststr = "MyTest";
	session.setAttribute("AppContextKey", teststr);
	java.lang.String stringObj = "This test my Application Context From the Viewer";
	session.setAttribute("AppContextValue", stringObj);
	String redirectURL = "LINK TO URL";
	response.sendRedirect(redirectURL);	
%>


I also have a report file which is named AppContext.rptdesign.

Aferwards I'm trying to display the string in a data item.
The expression of the data item is:

try{
	MyTest.toString();
}catch(e){
	"My Object Was not Found";	
}


If I start run the Application I don't get the String! It can't find the Object.
In the book is and additional code snippet like this:

config = new EngineConfig();
HashMap hm = config.getAppContext();
hm.put("MyTest", stringObj);
config.setAppContext(hm);


Unfortunately I dont't know where to add this and there is not a description about it.

Cheers,
Samet




Re: Adding an object to the application context! (Book example: Integrating and Extending) [message #991551 is a reply to message #991469] Wed, 19 December 2012 18:08 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Samet

This code:
config = new EngineConfig();
HashMap hm = config.getAppContext();
hm.put("MyTest", stringObj);
config.setAppContext(hm);

Is only if you are using the engine api. Are you using the Viewer? If so you have to add a jsp page to the viewer with code like:
<%
java.lang.String teststr = "MyTest";
session.setAttribute("AppContextKey", teststr);
java.lang.String stringObj = "This test my Application Context From the Viewer";
session.setAttribute("AppContextValue", stringObj);
String redirectURL = "LINK TO URL";
response.sendRedirect(redirectURL);
%>
and call it before going into the report. the LINK to URL should be the url to view the report.

Jason
Re: Adding an object to the application context! (Book example: Integrating and Extending) [message #991631 is a reply to message #991551] Wed, 19 December 2012 22:18 Go to previous messageGo to next message
Samo B. is currently offline Samo B.
Messages: 41
Registered: December 2012
Member
Hey Jason,

first of all thank you for replying.

Yes, I'm using the BIRT viewer. I chose a wrong description with "Link to URL"
it should be "Linkt to the report" so there is already the link to my report.

Just to clarify:

If have a web project with the jsp file (the code like you can see above) and a project which includes my report.
I can start my jsp file and after that it is forwarding to the report but I still can't get the AppContext in my report to display the variable.

regards,
Samet


Re: Adding an object to the application context! (Book example: Integrating and Extending) [message #992048 is a reply to message #991631] Thu, 20 December 2012 18:56 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Is the JSP that you added in the same web app context or a different one?

Jason
Re: Adding an object to the application context! (Book example: Integrating and Extending) [message #992274 is a reply to message #992048] Fri, 21 December 2012 09:01 Go to previous message
Samo B. is currently offline Samo B.
Messages: 41
Registered: December 2012
Member
I'm not sure what do you mean with the web app context?!
Could you explain it?

Regards,
Samet
Previous Topic:.getExpressionValue("row[CUSTOMERNAME]" returns a NULL ! WHY?
Next Topic:Yearly/Quarterly Report in Crosstab
Goto Forum:
  


Current Time: Thu Oct 23 15:56:19 GMT 2014

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

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