TOC PREV NEXT INDEX




Creating and Configuring a StormBase


This section covers the basics of setting up ice.storm.StormBase, which is the main class exposing the core functionality of the ICEbrowser SDK. For a thorough example, see Tutorial: Building a Browser.

Your code requires at least one import statement. The ice.storm package is always required.

You can then create the StormBase object:

StormBase stormBase = new StormBase( );
 

This object manages the pilots and scripter, keeps track of the history, displays the content in the GUI component, and so on.

Configuring GUI Toolkit Support

The ICEbrowser SDK is GUI toolkit-neutral. The core classes do not depend on heavyweight AWT or lightweight Swing components. When the core needs a reference to a GUI, it uses only the most basic classes, such as java.awt.Component, java.awt.Graphics, and java.awt.Color.

Your application is responsible for creating GUI elements such as navigation buttons, location fields, and so on. Make sure your application provides its own callback or container, so that it can use any widget set required.

To specify the GUI toolkit that the StormBase and the pilots use, use the following method:

// Tell StormBase and the pilots to use Swing

stormBase.setComponentToolkitName("swing");
 

Form controls inside rendered Web pages are then displayed using the chosen GUI toolkit.

You can specify either the AWT or Swing toolkit ("awt" or "swing").

SWT applications are supported via the SWT_AWT Bridge component. When using ICEbrowser with an SWT application, you must still configure the toolkit mode to either "awt" or "swing". Note that HTML form controls are rendered using the configured toolkit and not using native SWT components.

Example: Using Swing

The following code example shows a Swing configuration:

import ice.storm.StormBase;

import javax.swing.*;
 
public class Swing {

    final static public void main(String args[]) {

         StormBase stormBase = new StormBase();

         stormBase.setComponentToolkitName("swing");

         JFrame f = new JFrame("Web Viewer");

         JPanel htmlPanel = new JPanel();

         f.getContentPane().add(htmlPanel);

         stormBase.setContainer(htmlPanel,"demoPanel");

         f.setSize(300,300);

         f.setVisible(true);

         stormBase.renderContent("http://www.icesoft.com",null,"demoPanel");

    }

}
 
Configuring Protocol Handlers

The ICEbrowser SDK contains a custom factory for specifying java.net.URLStreamHandler objects. To install the custom factory, place a call similar to the following at the beginning of your application:

ice.util.net.URLStreamHandlerFactory f = new 

    ice.util.net.URLStreamHandlerFactory( );

URL.setURLStreamHandlerFactory(f);
 

Install the custom factory with ib6http.jar on the classpath to start using the HTTP protocol handler, which provides additional support for cookies, authentication, and caching:

ice.util.net.URLStreamHandlerFactory.addStreamHandler("http");
 

If you are not using HTTP/SSL, use the following code to remove the default HTTPS stream handler:

ice.util.net.URLStreamHandlerFactory.removeStreamHandler("https");
 

The HTTP stream handler can be removed similarly.

Configuring the Browser Emulation Mode

You can optionally configure your application to emulate MSIE or Netscape Navigator. This should be done after the StormBase has been initialized and before any content is rendered.

The emulation you choose depends on the content to be rendered. If the content is 100% W3C-compliant, rendering will likely be flawless and any emulation setting will work. However, if the content is non-compliant or uses many MSIE- or Netscape-proprietary functions, you will likely have better rendering if you configure your application to use the appropriate emulation.

If your application will support JavaScript, choosing an emulation mode is of particular importance because many JavaScripts detect the kind of browser and run the script accordingly.

If your content is proprietary and not W3C-compliant, you should consider making it compliant to ensure that it works with all browsers now and in the future.

To configure a particular mode, set the following property:

ice.browser.emulation="option"
 

where option is ie, ns (deprecated), or ns6. Any other value means that the emulation-specific code is not run, which is the default behavior

The emulation mode can be set dynamically at runtime; for more information, see System Properties.

HTTP User-Agent String

The HTTP User-Agent string is set automatically based on the currently set browser emulation mode.

In ICEbrowser versions before 6.0, the HTTP User-Agent string had to be set separately by the application using the ice.browser.http.agent system property, so a change to the browser emulation mode usually had to be accompanied with a corresponding setting of the HTTP user agent string. That step is no longer required. However, you still can use that system property to override the default User-Agent string.



Copyright 2005. ICEsoft Technologies, Inc.
http://www.icesoft.com

TOC PREV NEXT INDEX