| Browser local html with ESWT [message #638059] |
Tue, 09 November 2010 14:21  |
Felipe Messages: 1 Registered: November 2010 |
Junior Member |
|
|
Hello,
I'm doing an app to Nokia devices using ESWT. In order to create the app help, I created a html file with the help instructions and use the Browser class to open it.
try {
browser = new Browser(getShell(), SWT.NONE);
} catch (SWTError e) {
e.printStackTrace();
}
if (browser != null) {
StringBuffer buf = new StringBuffer();
try {
InputStream inputStreamTxt = null;
inputStreamTxt = this.getClass().getResourceAsStream("/help/index_test.html");
int c;
while ((c = inputStreamTxt.read()) != -1) {
buf.append((char) c);
}
inputStreamTxt.close();
} catch (IOException e) {
e.printStackTrace();
}
browser.setText(buf.toString());
}
When I open the help screen at the phone app, I renders the HTML, but doesn't load the images. I already tryed all kinds of paths.
<p><img src="figure-1.jpg" alt="alt text"/></p>
<p><img src="/figure-1.jpg" alt="alt text"/></p>
<p><img src="./figure-1.jpg" alt="alt text"/></p>
Please help me.
|
|
|
| Re: Browser local html with ESWT [message #638262 is a reply to message #638059] |
Wed, 10 November 2010 10:01  |
Grant Gayed Messages: 2128 Registered: July 2009 |
Senior Member |
|
|
Hi,
When Browser content is set via setText() it does not have a base directory
for resolving relative links. I assume that you're using setText() instead
of setUrl() because your .html file and its images are contained within your
plugin's .jar. Assuming so, you should determine the location that your
plug-in's files have been auto-extracted to by eclipse and then setUrl() to
the .html. For an example of determing where a file has been auto-extracted
to see the code snippet that's part of
http://www.eclipse.org/swt/faq.php#specifyxulrunner .
If I've made an incorrect assumption then please follow up here.
Grant
<felipelcoutinho@gmail.com> wrote in message
news:ibc6p6$oad$1@news.eclipse.org...
> Hello,
>
> I'm doing an app to Nokia devices using ESWT. In order to create the app
> help, I created a html file with the help instructions and use the Browser
> class to open it.
>
>
> try {
> browser = new Browser(getShell(), SWT.NONE);
> } catch (SWTError e) {
> e.printStackTrace();
> }
>
> if (browser != null) {
> StringBuffer buf = new StringBuffer();
> try {
> InputStream inputStreamTxt = null;
> inputStreamTxt =
> this.getClass().getResourceAsStream("/help/index_test.html");
>
> int c;
> while ((c = inputStreamTxt.read()) != -1) {
> buf.append((char) c);
> }
> inputStreamTxt.close();
>
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> browser.setText(buf.toString());
> }
>
>
> When I open the help screen at the phone app, I renders the HTML, but
> doesn't load the images. I already tryed all kinds of paths.
>
>
> <p><img src="figure-1.jpg" alt="alt text"/></p>
>
>
>
> <p><img src="/figure-1.jpg" alt="alt text"/></p>
>
>
>
> <p><img src="./figure-1.jpg" alt="alt text"/></p>
>
>
> Please help me.
|
|
|
Powered by
FUDForum. Page generated in 0.01450 seconds