Teen Programmers Unite  


Return to forum top

HTML Object

Posted by DragonWolf [send private reply] at January 24, 2003, 08:58:45 AM

Just reading the posts about embedded HTML (or visa versa).

Are the advantages better than the disadvantages that there would be to making an alternative to Java's HTMLDocument Class? That would allow programmers to easily make HTML Pages in pure Java, removing the messy HTML.

HTMLDocument Class
HTMLForm Class
HTMLTable Class

Works like JComponent in swing. You can add a Form to an HTMLDocument.

This could then be used to build "Correct" HTML/XHTML/DHTML/(Your choice of what you want it to output).

I'm assuming someone has done this already. Anyone know where I might find this? I'd seriously consider using it.

Posted by AnyoneEB [send private reply] at January 24, 2003, 10:52:18 AM

Do you mean something like this: http://xml.apache.org/xalan-j/apidocs/org/w3c/dom/html/package-tree.html ? Or maybe something else here: http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=java+...

Posted by DragonWolf [send private reply] at January 24, 2003, 11:53:40 AM

nah, higher level than that..
more like the swing library.

Posted by buzgub [send private reply] at January 25, 2003, 11:52:04 PM

This is something like the "Web forms" stuff in ASP.NET, which attempts to put an event-based programming model such as the one you describe on something delivered over the web. Mono are implementing it.

Posted by DragonWolf [send private reply] at January 28, 2003, 06:56:42 AM


That isn't what I mean't, but still interesting.

when I said the java swing/awt I didn't mean with all the listeners and controllers. I just mean how you can add/remove objects from a container/pane.

So you have an HTML document object, then you can add headers to it, add tables to it, etc. Then the tables can have rows/columns/elements added to them, and in-turn image/span/div/form/etc objects.

It would then run server side, and generate the HTML (or any other output you want (XHTML,DHTML,XML,etc) to be sent back to the client.

Posted by gian [send private reply] at January 28, 2003, 07:22:12 AM

"That would allow programmers to easily make HTML Pages in pure Java, removing the messy HTML."

It really depends who is writing the HTML... it seems to me that it would be much easier to make a mess of Java than HTML.

Posted by DragonWolf [send private reply] at January 31, 2003, 06:03:04 AM

I find embedding multiple languages into one file is always messy. Below is a sample of what I was thinking of.


HTMLDocument myDoc = new HTMLDocument("My Title Bar");

myDoc.addHeader(new HTMLHeader("content-type", "text/html"));
myDoc.addHeader(new HTMLHeader("author","John Doe"));
myDoc.addHeader(new File("myHeaders.html");

myDoc.addScript("javascript", new File("myjsscript.js"))

HTMLTable myTable = new HTMLTable();
HTMLRow currentRow

while (some condition) {
currentRow = new HTMLRow();
currentRow.add("value3", "10%", new HTMLColor(50,30,150));

myDoc.add(new File("myfooter.html");

out.print(myDoc); // For HTML 4.0
out.print(myDoc.toXHTML); // For XHTML 1.1


You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.