Skip to main content

LWUIT HtmlComponent Lines don't get wrapped + Parser Problem

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
cond
Offline
Joined: 2011-06-22

Hello all,

I also asked this on Stackoverflow.

I'm using LWUIT now for 2 days, so I'm still a newbie.

First Question:I think I'm facing a simple layout problem. I'm embedding a HTMLComponent on a Form via LWUIT, this HTMLComponent displays a local HTML file. The result has no line wrapping but instead scrolls in X direction.

How can I change this behaviour?

Second Question:I also have some tags in the files which aren't really supported.
How can I still parse the files, without removing those tags manually? Do I need to modify my DocumentRequestHandler or where can I do that?Best Regards

Third Question:

I have some links in my files to other local files, when I click them, the current RequestHandler appends "null" in front of them, where can I influence this behaviour?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

First when asking questions try to indicate whether you are using the SVN version or 1.4.

I'm guessing you just called setScrollable(true) which triggered X scrolling as well. You should not touch scrolling and let the HTML component handle it (see the LWUITDemo and browser demo). Try your HTML file in those demos and see how it works.

Usually unsupported tags are just ignored, e.g. script has a fallback where you can optionally print text when script isn't available.

Which request handler are you using? The one from LWUIT SVN, the one from the browser demo or the one from LWUIT4IO?

cond
Offline
Joined: 2011-06-22

Thank you for your answer.

It's svn from last week.

Code I'm using:

Form test = new Form();

String fileName = "/" + InDevGuide.chosenLanguage +"/contents/"+ guid;

FileRequestHandler handler = new FileRequestHandler();

HTMLComponent htmlC = new HTMLComponent(handler);

htmlC.setIgnoreCSS(true); //this line doesn't change the wrapping

test.addComponent(htmlC);

htmlC.setPage(fileName);

test.show();

Requesthandler I'm using:

import com.sun.lwuit.html.DocumentInfo;

import com.sun.lwuit.html.DocumentRequestHandler;

import java.io.ByteArrayInputStream;

import java.io.InputStream;

class FileRequestHandler implements DocumentRequestHandler {

public InputStream resourceRequested(DocumentInfo docInfo) {

String url=docInfo.getUrl();

url=url.substring(4);

System.out.println(url);

return getClass().getResourceAsStream(url);

}

private InputStream getErrorStream(String err) {

err="<body>"+err+"</body>";

ByteArrayInputStream bais =

new ByteArrayInputStream(err.getBytes());

return bais;

}

I tried it with a different file, but this one looks really strange:

http://pastebin.com/iSmZ767d

vprise
Offline
Joined: 2003-11-07

Set the layout of the form to border layout and add the html component appropriately, disable form scrolloing:

</p>
<p>frm.setScrollable(false);</p>
<p>frm.setLayout(new BorderLayout());</p>
<p>frm.addComponent(BorderLayout.CENTER, htmlCmp);</p>
<p>