Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Relative paths in a Browser not working in RCP app(...but they work in the HTML document viewed in an external browser)
Relative paths in a Browser not working in RCP app [message #714603] Thu, 11 August 2011 03:36 Go to next message
SBS  is currently offline SBS Friend
Messages: 57
Registered: January 2011
Member
I have a Browser widget in a view as part of my RCP application. I am using browser.setText(html) to load the content and within that content are <img> tags where the src is specified as a relative path using "../images/pic.jpg". This is not working and the image is not displayed.

The question is, where exactly does it think the current directory '.' is so that I can work out where it thinks '..' points to? If I use the system property to print out the current user directory and place the image in the "correct" relative path it still doesn't work. I use a similar relative path to access other resources such as a Lucene index from the same application and that is all working, it's just the links in the Browser that fail.

So, I guess the question is where does the Browser think the current working directory is? I can use relative paths in a static HTML page when it is displayed in a standard external web browser so I imagine this feature should be supported in the embedded Browser object right? The issue I suppose is that I am not loading the HTML using a URL but setting it directyly using setText().

Thanks,

-sbs
Re: Relative paths in a Browser not working in RCP app [message #714780 is a reply to message #714603] Thu, 11 August 2011 13:16 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
Hi,

I think that
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet137.java
demonstrates what you want (it sets the <base> href).

If this does not help your case then please follow up here.

Grant


On 8/10/2011 11:36 PM, SBS wrote:
> I have a Browser widget in a view as part of my RCP application. I am
> using browser.setText(html) to load the content and within that content
> are <img> tags where the src is specified as a relative path using
> "../images/pic.jpg". This is not working and the image is not displayed.
>
> The question is, where exactly does it think the current directory '.'
> is so that I can work out where it thinks '..' points to? If I use the
> system property to print out the current user directory and place the
> image in the "correct" relative path it still doesn't work. I use a
> similar relative path to access other resources such as a Lucene index
> from the same application and that is all working, it's just the links
> in the Browser that fail.
>
> So, I guess the question is where does the Browser think the current
> working directory is? I can use relative paths in a static HTML page
> when it is displayed in a standard external web browser so I imagine
> this feature should be supported in the embedded Browser object right?
> The issue I suppose is that I am not loading the HTML using a URL but
> setting it directyly using setText().
>
> Thanks,
>
> -sbs
Re: Relative paths in a Browser not working in RCP app [message #714846 is a reply to message #714780] Thu, 11 August 2011 15:35 Go to previous messageGo to next message
SBS  is currently offline SBS Friend
Messages: 57
Registered: January 2011
Member
Thanks for that but I still can't get it working.

If I specify base using an absolute path it works but that's not what I need. So if I say:

<base href="file://C:\HTML\">

it works but this:

<base href="file://..\HTML/">

doesn't work, not even in an HTML file viewed in a standard browser with the HTML file in the correct location for that relative path to be correct.

Am I missing something?

Thanks,

-sbs
Re: Relative paths in a Browser not working in RCP app [message #714864 is a reply to message #714846] Thu, 11 August 2011 16:25 Go to previous messageGo to next message
SBS  is currently offline SBS Friend
Messages: 57
Registered: January 2011
Member
I have just discovered that the href in a <base> tag does not permit relative paths. Did I misinterpret the example, i.e. is there a different way of doing this that you were thinking of?
Re: Relative paths in a Browser not working in RCP app [message #715232 is a reply to message #714864] Fri, 12 August 2011 20:44 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
The <base> tag allows you to specify a location from which _subsequent_
relative paths will be computed, so it needs to be absolute.

Are you trying to reference image files that are shipped in a plug-in
jar? If so, eclipse core provides API for querying the absolute
location that a resource within a plug-in jar is auto-extracted to by
the platform. Or are you trying to accomplish something else?

Grant


On 8/11/2011 12:25 PM, SBS wrote:
> I have just discovered that the href in a <base> tag does not permit
> relative paths. Did I misinterpret the example, i.e. is there a
> different way of doing this that you were thinking of?
Previous Topic:Setting Status Line.
Next Topic:Does WorkbenchStatusDialogManager.setSupportAreaProvider work?
Goto Forum:
  


Current Time: Thu Dec 18 00:46:29 GMT 2014

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

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