Extent of the HTML Support

45 views
Skip to first unread message

e.andres.h...@gmail.com

unread,
Mar 1, 2014, 2:57:54 PM3/1/14
to codenameone...@googlegroups.com
The app I'm building is simply meant to display a number of pages of text and diagrams. I have an index (in a list) that creates a new form. That form then I attempt to load HTML from the files representing the chapters of my instruction booklet.


The only way I could get it to work was using:


String text = "";
try {
  InputStream in = FileSystemStorage.getInstance().openInputStream(CHAPTER_DIRECTORY+"/"+title);
  if (in != null){
    text = com.codename1.io.Util.readToString(in);
    in.close();
  }
} catch (IOException ex) {
  System.out.println(ex);
  text = "Read Error";
  html = new HTMLElement("html");
  html.setText("READ ERROR");
}

Form f = new Form(title);
f.setLayout(new BorderLayout());
HTMLComponent hc = new HTMLComponent();
hc.setBodyText(text);
f.addComponent(BorderLayout.CENTER,hc);
f.show();

Reading through the documentation it seems I should be trying to do something more like this, since it isn't deprecated:
WebBrowser wb = new WebBrowser();
wb.setScrollable(true);
wb.setURL("http://"+CHAPTER_DIRECTORY+"/"+title);

However whenever I try to do that I don't get my content to load.


Furthermore I have already run into one instance of HTML not appearing to be supported (at least in the simulator) being the sup and sub tags (superscript and subscript)


Do you have a document outlining the HTML tags that you do support ? For instance do you support image tags ? If I see html tags unsupported in the simulator am I to assume that they won't work in the iOS device ?


Thank you in advance

Steve Hannah

unread,
Mar 1, 2014, 3:02:44 PM3/1/14
to codenameone...@googlegroups.com
All of the modern platforms (e.g. the Simulator with JavaFX on the classpath, iOS, Android, Win Phone) provide native (i.e. webkit or equivalent) web browser components.  The WebBrowser class is an abstraction that wraps either the BrowserComponent (for modern platforms) or HTMLComponent (for J2ME & older BB).

BrowserComponent can handle any HTML that Chrome/Safari can handle.
HTMLComponent (the deprecated one) you only need to worry about if you are running on J2ME or BB.  It is extremely limited.  E.g. no javascript.

Steve


--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/ffb50c12-1174-47f6-87e1-b260de7a4dec%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Steve Hannah
Web Lite Solutions Corp.

Shai Almog

unread,
Mar 2, 2014, 1:08:38 AM3/2/14
to codenameone...@googlegroups.com
Make sure you are using JDK 1.7 update 6 or newer with Java FX enabled for the JDK and configured properly. Otherwise the browser component won't work in the simulator.
Reply all
Reply to author
Forward
0 new messages