HomeSitemapSearchDownload


Products
Successes
Developer info

News
About WebLogic

Tech infoOverviewGetting startedDocumentationCustomer Support

Creating dynamic documents with htmlKona

htmlKona provides an object-oriented interface to the HTML environment that allows you to format complex HTML documents in Java. htmlKona can be used with Java-enabled Web browsers like WebLogic, JavaSoft's Java WebServer, and Netscape's Enterprise Server.

With htmlKona and WebLogic's database access products like dbKona and the WebLogic jDriver JDBC drivers, you can programmatically construct pages using the object-oriented power of Java.

htmlKona treats the HTML page like a canvas. Instead of using a tagged syntax to mark up a page, you create a page container object and add htmlKona elements to it. The HTML for your page is automatically rendered.

Here are some examples that show you what htmlKona can do and demonstrate how easy it is to use. Included are examples for using htmlKona with the Java-enabled servers, the WebLogic Server and JavaSoft's Java WebServer. Many of the examples have been registered (commented out) in the weblogic.properties file that was shipped with the distribution, and you can test these examples yourself by uncommenting them in the properties file and restarting the WebLogic Server.

Many of these examples generate HTML that takes advantage of browser extensions to HTML. The latest version of htmlKona supports the HTML 4.0 specifications now under review, as well as JavaScript and many browser extensions.

Note: You can view the example code, but the examples are temporarily out of service.

Hello World!!
This simple example demonstrates htmlKona object-based HTML generation. It outputs the text "Hello World!!" with horizontal borders. As with all htmlKona programs, no explicit HTML is required.

Adding font and background elements
This example demonstrates a little more complicated HTML generation. It displays "Hello World!" in a variety of HTML formats and adds a background image to the page.

Using templates and named components
This example demonstrates the use of a page template and the construction of a page using named components. Since htmlKona's HtmlElements are accessible by name, you can replace one element with another. Take a look at the source code to see how you can change, replace, and add to elements.

Displaying frames
You use an htmlKona FrameElement to construct frames in htmlKona. A FrameElement is a multi-part htmlKona object; that is, it can contain other htmlKona objects. In this case, you create a FrameElement and then add one FrameSetElement for each frame you want to display. Finally, you add the FrameElement to your htmlKona page.

In this example, each frame invokes a CGI script with a different argument.

Top of the page

Using applets
You add applets to your htmlKona webpage just like any other object: as an AppletElement. Like many other htmlKona elements, AppletElements are constructed with an AlignType object to set its position on the page.

Using JavaScript
htmlKona's ScriptElement lets you add JavaScript expressions to your webpage. In this example, we use JavaScript to build a simple calculator.

htmlKona's elegant FormElement object, a multipart htmlElements, makes this page easy to put together. You add InputElements to a FormElement to build a form. Here we've arranged the InputElements for the form in a TableElement to simplify layout.

Using client-side image maps
htmlKona also supports the use of images for client-side image maps. Unlike serverside image maps, client-side image maps don't require a roundtrip to the server to process each event.

Creating a client-side image map is done in three steps; first, you add an image with the appropriate attributes. Then you construct an htmlKona MapElement and add AreaElements, one for each region on the image map, to it.

More on interactive forms in htmlKona
This example demonstrates how htmlKona simplifies working with forms and context data. In this example, we display a table and ask the user to add rows to it interactively.

Top of the page

Displaying query results from a database
This example demonstrates how htmlKona makes it easy to display query results in an HTML format.

htmlKona's TableElement class has methods for building a table from query results. You can also use an htmlKona LiteralElement to add a dbKona DataSet directly to a webpage. You can view both methods in this example.

Working with an externally defined HTML document
htmlKona also allows you to combine a document defined with an HTML authoring tool and dynamically generated HTML components at run-time. In this example, two tables are constructed from a simple database query and then included in the document. This is similar to the "document-centric" approach taken by many of the HTML/DB products.

Creating a simple mail merge document
In this example, we demonstrate how htmlKona allows for easy document/DB integration. We prepared an HTML mail merge document called "formletter" that we combine with data from a database to produce a set of letters to employees.

Constructing forms with database metadata
Because you use Java--a first-class programming language--to put together htmlKona pages, it's easy to manage the dynamic display of data from a database. In this example, we use htmlKona to dynamically construct a form based on metadata stored in a database.

Top of the page

Displaying an image from a file system
This example shows how you use htmlKona to retrieve and display an image from the file system as a link element.

Displaying images stored in a database
You can also use htmlKona to display images that are stored as binary large object data in a database. This example retrieves two gifs from database based on key names and displays them as link elements in a table.

Playing audio clips
You can also store audio clips as binary large object data in a database and use htmlKona to retrieve them into an HTML environment. This example retrieves an audio clip from the database that runs on the Netscape audio player.

More code examples

Copyright © 1998-2000 by BEA Systems, Inc. All rights reserved.

Last updated 5/25/98