Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » rwt-resource for browser widget
rwt-resource for browser widget [message #1095051] Mon, 26 August 2013 14:55 Go to next message
Julia Kurde is currently offline Julia KurdeFriend
Messages: 91
Registered: November 2011
Location: Berlin, Germany
Member
Hi,

I need some help with rwt-resources that are loaded in an html file:

I have a browser widget (org.eclipse.swt.browser.Browser) in a view which should display an html file set by browser.setText(html). This html file uses some javaScript files that are included in the header.

To make these files available I want to register them as rwt-resources. This is done by a static method in class eub.jlzhinternal.chartview.utils.ChartUtilsJS (located in the same plugin as the javaScript files: eub.jlzhinternal).
E.g. one of the javaScript files is "/eub.jlzhinternal/js/date_format.js".
If I understood it correctly, it should be registered like
InputStream inputStream = ChartUtilsJS.class.getClassLoader().getResourceAsStream("js/date_format.js");
RWT.getResourceManager().register("js/date_format.js", inputStream);

To include this file in the html header I then generate a String like
"<script language=\"javascript\" type=\"text/javascript\" src=\"" + 
    RWT.getResourceManager().getLocation("js/date_format.js") + "\"></script>";

But already the input stream from the class loader is null!
So how do I get the input stream correclty?

Thanks for your help!
Julia
Re: rwt-resource for browser widget [message #1095574 is a reply to message #1095051] Tue, 27 August 2013 08:32 Go to previous messageGo to next message
Manu Dev is currently offline Manu DevFriend
Messages: 1
Registered: July 2009
Junior Member
I have been doing this and it worked for me.
Thread.currentThread().getContextClassLoader().getResourceAsStream("folder/filename");


Also if your "js" folder is not inside META-INF folder then make sure your "js" folder is in the class path (Bundle-ClassPath: tag)
Hope this helps.
Re: rwt-resource for browser widget [message #1095901 is a reply to message #1095574] Tue, 27 August 2013 17:36 Go to previous messageGo to next message
Julia Kurde is currently offline Julia KurdeFriend
Messages: 91
Registered: November 2011
Location: Berlin, Germany
Member
You were right, the "js" folder was not on the class path.

I added it in the build.properties:
output.jlzhinternal.jar = bin/
source.jlzhinternal.jar = src/
bin.includes = bin/,\
               META-INF/,\
               jlzhinternal.jar,\
               js/
jars.compile.order = jlzhinternal.jar

Is that correct?
Because still the input stream returned by

ChartUtilsJS.class.getClassLoader().getResourceAsStream("js/date_format.js") or
Thread.currentThread().getContextClassLoader().getResourceAsStream("js/date_format.js")

is null!
Re: rwt-resource for browser widget [message #1097849 is a reply to message #1095901] Fri, 30 August 2013 08:37 Go to previous message
Julia Kurde is currently offline Julia KurdeFriend
Messages: 91
Registered: November 2011
Location: Berlin, Germany
Member
Isn't this a standard scenario? All I want to do is display an html file, which is generated during runtime and depends on some java script files that are stored somewhere.

In the RCP this is easy because I can just access the file system directly.

But how to do that in RAP?

The java script files are static and are the same for all users in all sessions.

The html file is generated when a certain view is opend by the user and will be deleted when the view is closed. So it is a temporary file used only by one user in one session.

Can somebody please point me to an example?

Thanks!
Julia

Previous Topic:Configure custom HTTP Header in RWTServlet main response
Next Topic:How to size Composite based on CSS background-image?
Goto Forum:
  


Current Time: Fri Apr 26 06:56:17 GMT 2024

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

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

Back to the top