Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to create a url to a generated resource?
How to create a url to a generated resource? [message #657608] Thu, 03 March 2011 13:22 Go to next message
Paul Ramsden is currently offline Paul RamsdenFriend
Messages: 84
Registered: February 2011
Location: BW, Germany
Member
I am trying to use BIRT in a RAP app to display reports and charts. For reports, BIRT generates Images and HTML and loads the images via the HTML. This is not working for me as the URL to the image returns 404 NotFound.

I downloaded the examples from http://wiki.eclipse.org/RAP/BIRT_Integration but the report example does not work either.

I can see that an image is generated and saved to

D:\eclipse-rcp-helios-SR1-win32\eclipse\workspace\.metadata\ .plugins\org.eclipse.rap.ui\context\rwt-resources\1.23\2.30\ 0.31\0.32

The HTML then tries to load the image using

<img id="__bookmark_1" src="/1.23/2.30/0.31/0.32" alt="" style=" width: 400pt; height: 250pt;display: block;"></img>


but gets a 404.

Do I need to register a resource alias or something in order to get at that image?

(The Chart example works ok but this uses an Image in a Label on a Canvas which is quite a different approach)

I am using RAP 1.3 and BIRT 2.6.

[Updated on: Thu, 03 March 2011 13:23]

Report message to a moderator

Re: How to create a url to a generated resource? [message #657621 is a reply to message #657608] Thu, 03 March 2011 13:36 Go to previous messageGo to next message
Benjamin Wolff is currently offline Benjamin WolffFriend
Messages: 136
Registered: July 2009
Senior Member
Hi paulr,

please have a look at this FAQ entry: http://wiki.eclipse.org/RAP/FAQ#How_to_display_dynamically_c reated_images.3F

To my experience this is the best approach to display dynamic generated content. I use it for displaying images and even PDF or Excel files!
When BIRT creates an image and you have a handle to this file you can display this image in an embedded browser widget inside the application or you can provide a link to it. This way you can leverage the browser environment and its ability to handle images and other files. You can also server a HTML page in the browser widget, the link to the image will be the link to the service handler described in the FAQ entry.

In my experience, this is a very flexible approch, you don't need to bother with registering or deregistering ressources, unless they are really static.

Fell free to ask if you have more questions or problems.

HTH,
Ben


Am 03.03.2011 14:22, schrieb paulr:
> I am trying to use BIRT in a RAP app to display reports and charts. For reports, BIRT generates Images and HTML and loads the images via the HTML. This is not working for me as the URL to the image returns 404 NotFound.
>
> I downloaded the examples from http://wiki.eclipse.org/RAP/BIRT_Integration but the report example does not work either.
>
> I can see that an image is generated and saved to
> D:\eclipse-rcp-helios-SR1-win32\eclipse\workspace\.metadata\ .plugins\org.eclipse.rap.ui\context\rwt-resources\1.23\2.30\ 0.31\0.32
>
> The HTML then tries to load the image using
>
> <img id="__bookmark_1" src="/1.23/2.30/0.31/0.32" alt="" style=" width: 400pt; height: 250pt;display: block;"></img>
>
> but gets a 404.
>
> Do I need to register a resource alias or something in order to get at that image?
>
> (The Chart example works ok but this uses an Image in a Label on a Canvas which is quite a different approach)
Re: How to create a url to a generated resource? [message #657846 is a reply to message #657621] Fri, 04 March 2011 10:39 Go to previous messageGo to next message
Paul Ramsden is currently offline Paul RamsdenFriend
Messages: 84
Registered: February 2011
Location: BW, Germany
Member
Thanks Ben,

looks interesting but couldn't figure out how to get BIRT to generate just an image. Sure it's possible, just didn't spot it.

I have actually managed to get my original attempt to work by using a different ImageHandler -- HTMLCompleteImageHandler in place of HTMLServerImageHandler.

			// Render the report to HTML
			renderOptions = new HTMLRenderOption();
			renderOptions.setOutputFormat(HTMLRenderOption.HTML);
			renderOptions.setOutputStream(outputStream);

			// Get the path to the local context directory to save the rendered
			// chart image
			String webAppBase = (ContextProvider.getWebAppBase()).replaceAll("\\\\", "/");
			String path = webAppBase + reportDirServer + RWT.getSessionStore().getId();

			// Handle the image path

			//renderOptions.setImageHandler(new HTMLServerImageHandler());
			renderOptions.setImageHandler(new HTMLCompleteImageHandler());
			renderOptions.setImageDirectory(path);
			renderOptions.setBaseImageURL(URL + reportDirServer + RWT.getSessionStore().getId());

			task.setRenderOption(renderOptions);
			task.run();
			task.close();


UPDATE
Forget that idea. When I look at the source code I see that the IMG src is 'file:/D:/...' which is really not what I want. So the question is still open - why can I not get at these resources using HTMLServerImageHandler?

[Updated on: Tue, 08 March 2011 07:19]

Report message to a moderator

Re: How to create a url to a generated resource? [message #658885 is a reply to message #657846] Thu, 10 March 2011 10:12 Go to previous messageGo to next message
Paul Ramsden is currently offline Paul RamsdenFriend
Messages: 84
Registered: February 2011
Location: BW, Germany
Member
Finally, got it working.

I have described the solution on my blog http://blackforestcoder.blogspot.com/2011/03/rap-birt-on-web sphere.html but the basic idea was to get BIRT to output the images to a folder under rwt-resources. Then the server was able to locate the images. Any way, read the blog post for more info.
Re: How to create a url to a generated resource? [message #674275 is a reply to message #658885] Thu, 26 May 2011 11:39 Go to previous messageGo to next message
Nikolai Raitsev is currently offline Nikolai RaitsevFriend
Messages: 102
Registered: July 2009
Senior Member
Hi Paul,

after updating my target from RAP 1.4M(not sure wich version) to the latest RAP1.4RC I have noticed, that ContextProvider.getWebAppBase() was deleted. (See revision 1.11)

I'm using for temporary this call (copied it from revision 1.10), wich replaces getWebAppBase:

IEngineConfig engineConfig = RWTFactory.getConfigurationReader().getEngineConfig();
String webAppBase = engineConfig.getServerContextDir().toString(); 


Best regards,

Nikolai
Re: How to create a url to a generated resource? [message #696967 is a reply to message #674275] Fri, 15 July 2011 08:23 Go to previous messageGo to next message
Paul Ramsden is currently offline Paul RamsdenFriend
Messages: 84
Registered: February 2011
Location: BW, Germany
Member
Hi Nikolai

I just just got back to this project today and ran into this problem as soon as I upgraded to RAP 1.4. Thanks for the fix!

However, I noticed that the package name contains 'internal' which is usually a sign that it shouldn't be used directly by applications.

Any thoughts on that?

Regards

Paul
(no subject) [message #696993 is a reply to message #696967] Fri, 15 July 2011 09:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by:

Paul,

you are right, the content of 'internal' packages is not considered API
and therefore may change or vanish without prior notice.
The way out of this would be to describe your use case and the desired
API extension in an enhancement request.

Regards,
Rüdiger

On 15.07.2011 10:23, Paul Ramsden wrote:
> Hi Nikolai
> I just just got back to this project today and ran into this problem as
> soon as I upgraded to RAP 1.4. Thanks for the fix!
>
> However, I noticed that the package name contains 'internal' which is
> usually a sign that it shouldn't be used directly by applications.
>
> Any thoughts on that?
>
> Regards
>
> Paul

--
Rüdiger Herrmann

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: (no subject) [message #697822 is a reply to message #696993] Mon, 18 July 2011 06:42 Go to previous messageGo to next message
Paul Ramsden is currently offline Paul RamsdenFriend
Messages: 84
Registered: February 2011
Location: BW, Germany
Member
Hi Rüdiger

thanks for the interest. I have been trying to generate reports and chart in a RAP app using BIRT. My approach (see earlier posts in this thread) includes setting a path where BIRT outputs images. This path needs to be the context path which is why I'm trying to find the absolute path using the 'internal' classes. It could be that there is a better way to do this, of course.

Assuming this is the correct approach, I would need an API extension which returns the WebAppBase path.

Paul
Re: (no subject) [message #697903 is a reply to message #697822] Mon, 18 July 2011 09:45 Go to previous message
Eclipse UserFriend
Originally posted by:

Paul,

regardless how you obtain the web-app base, with putting your images
below 'rwt-resouces' you may interfere with internal workings of RAP as
well. This path is meant for resources that were registered with the
IResourceManager.
As far as I understand, BIRT resources don't necessarily have to lie
below 'rwt-resources'.
At least With RAP 1.5, the path of the web-app base in the local file
system can be obtained like so:
RWT.getRequest().getSession().getServletContext().getRealPath("foo")
Though I am not entirely sure, the same should also work for 1.4.

HTH
Rüdiger

On 18.07.2011 08:42, Paul Ramsden wrote:
> Hi Rüdiger
>
> thanks for the interest. I have been trying to generate reports and
> chart in a RAP app using BIRT. My approach (see earlier posts in this
> thread) includes setting a path where BIRT outputs images. This path
> needs to be the context path which is why I'm trying to find the
> absolute path using the 'internal' classes. It could be that there is a
> better way to do this, of course.
>
> Assuming this is the correct approach, I would need an API extension
> which returns the WebAppBase path.
>
> Paul

--
Rüdiger Herrmann

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:RAP deployment on Weblogic fails
Next Topic:PlatformUI.getPreferenceStore() without values?
Goto Forum:
  


Current Time: Thu Mar 28 23:01:34 GMT 2024

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

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

Back to the top