Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Changing report's application context when opening report in the report viewer
kallem
Hi,
in Java code I do pass parameters in the report through application context as it allows passing Java objects. In addition to Java code usage the report is shown in the report viewer using servlet mappings. Now when showing report in the report viewer I have a small problem as I didn't find any solution on how pass (or modify) report's application context. Is it even possible?
Is there any other way to pass Java objects in the report?
I am using scripted data source in the report.
Br, Kalle
Find more posts tagged with
Comments
JasonW
Take a look at this page:
http://wiki.eclipse.org/Adding_an_Object_to_the_Application_Context_for_the_Viewer_(BIRT)
Jason
kallem
Hi Jason,
and thanks for the helpful link. I couldn't get it work exactly like that but it helped.
I got into problems with session variables as they got reseted after the sendRedirect. Report just didn't receive any variables I set in the session. My application and BIRT report viewer are on the same server but on different webapps. I tried to figure out how to retain session variables but didn't succeed. Finally I overcome problem by assigning variables in the request object (request.setAttribute(...)) and then accessing them in report with reportContext.getHttpServletRequest().getAttribute(...).
I'd really like to know how to retain session variables when doing sendDirect like in example... What remains unclear to me in the example is the location of the presented JSP example file. Is it supposed to be in app folder or in birt folder?
- Kalle
JasonW
The appserver has to be setup to support cross context session sharing. In the example I was just adding it to the BIRT webapp and calling it first. The way you are doing it may be a bit more flexible for you. You can also call reportContext.getHttpServletRequest().getSession().get/setAttribute . This would allow you to take your request attribute and then store it in the birt context session.
Jason
kallem
I did enable cross context in the Tomcat configuration but didn't change individual webapp configs. Maybe I still try if that makes the difference..
- Kalle
kallem
Instead of using HttpServletResponse.sendRedirect I used RequestDispatcher.forward and for a while it seemed a satisfactory solution. Now I stumbled upon a problem with charts. When using forward charts aren't shown in the report viewer. I suppose this is a result of forwarding as when using redirect image urls refer to report viewer webapp.
So back to drawing board. So far I haven't found any working way to use sendRedirect from one webapp to other without loosing session and request attributes. Jason: is your example working in a way that it uses two webapps and first redirects control to other?
Btw. when BIRT taglib is used is there any possible way to pass Java objects to report as parameters? Or do I have to start doing object to text conversion?
- Kalle
JasonW
Can you not call a jsp from one ctx to the other with request vars and in the target jsp take the request vars and put them in the targets session?
Object type is currently not supported as a parameter type.
Jason
kallem
Yep, I have thought about same thing as you proposed. Problem with that was that my request vars grew too big so I dropped it. I have now tested using Json with report parameters and that seems satisfactory. Another possible solution I have also tried is to use files to store information which works fine. Only downside is the need to create files and their location..
- Kalle
JasonW
I would love to see how you implemented this with Json.
Jason
kallem
I completely moved away from passing the parameters inside the session or request objects. With Json I use report parameters. I might have been a little bit too short worded in my last reply..
Anyway, in the report I have a parameter for passing in the Json object as string. Report's data source is Scripted Data Source that catches this parameter, converts it to Json and reads the actual parameter what I have created in the application. Application uses vectors and arrays for data saving as they are easy to interpet in the report.
As I didn't want the parameters to be visible in the url I use BIRT taglib when opening the report.
I do still use report context to save report data when using report directly from application. This way I don't have to generate Json until preview is request.
- Kalle
ps. This is just a workaround as I'd still like to get params passed in the session to skip the Json conversions.
JasonW
Kalle,
Thanks for the update. It would be good if you could log a bugzilla entry for improvements the current model.
Jason