| Class Name: | HotJavaBrowserBean |
| Extends: | BeanDocumentPanel |
| Implements: | Externalizable, ComponentListener, BrowserHistoryListener, Observer, Serializable |
Purpose
The HotJava HTML Component is the encapsulation of about 80 percent of what a web browser does. Specifically, this is the HTML parsing and rendering engine used in the HotJava Browser. This component is a candidate for use in any application that requires display of documents or navigation similar to that found in web browsers.Key Properties
documentString - the URL for the current document as a string.Creation
HotJavaBrowserBean()Commonly Used Methods
clone()
setDocumentString() - set (and display) a document by specifying a URL as a string.
find() - search for a given string in the current document.
print()- print the current document.
This document describes the HTML JavaBean component. It is intended for both "component assemblers" who will be instantiating and connecting the bean in builder applications as well as Java developers who will be programatically accessing the component. It assumes that you are already familiar with JavaBeans. If terms like property, event, method, introspection, or serialization are unfamiliar, you may want to refer to the JavaBeans documentation or take the JavaBeans tutorial.Table of Contents
The HotJava HTML Component is a single, monolithic panel class that complies with the JavaBeans 1.0 specification. While the major browser functionality is contained within this single bean, there are also the Authenticator, Document Stack, and System State beans which provide supporting functionality.SecurityThere is also a normal Java class behind the bean that implements the methods. This class could also be used in Java applications. The danger with this is upward compatibility. If in the future browser functionality is provided as a collection of beans, rather than one, then the panel class becomes obsolete. Compatibility with the monolithic bean component will be maintained via bean aggregation, but the panel class, if used in Java applications, will have no such guarantee.
To support the possible future development directions, the intent is to keep this API as minimal as possible, while providing a full featured product. This is a difficult balance between making it easier to use, and providing an API that won't need to be broken in the future.
There are two types of security concerns with the HTML component: The security manager, which determines what it can do, and dealing with secure connections.Providing a Pop-Up MenuAn HTML component presents a difficult situation. The Bean specification says that security management is the responsibility of the bean container. Beans that are to be used everywhere need to be able to run under a security manager, while beans that are application specific may not need to. The HTML component is unique in that it is a bean that can have other beans or Java applets within it that can come from unknown sources, i.e. the web. If the HTML component were to just let its container worry about security, as recommended by the Bean specification, you could easily get into a situation where you are browsing the web and running applets totally unprotected. To protect against this, when the bean is instantiated, if it doesn't detect a security manager it will install one. The installed security manager will only affect applets within the bean. This still allows applets to take advantage of a lenient container-supplied security manager, but it does provide good default security behavior. We also provide an option for the case where an application needs to have its own security manager in addition to the HTML Component's security manager. The application can have both managers running simultaneously by instantiating the DelegatingSecurityManager. The only drawback to this method is that the DelegatingSecurityManager assumes that the HTML Component Jar file is on the CLASSPATH.
To deal with secure connections, we need to handle authentication. Dealing with authentication means supplying a user interface, something we are trying to avoid in the bean. As a compromise, we are breaking the monolithic model, and supplying the HotJava Authenticator Bean. This release defines the interface used by this bean, and provides a default implementation. Developers may use this version or override its behavior. If the authenticator bean is not wired into the container, the HTML component will work fine, but it will not be able to connect to secure sites.
The right mouse pop-up menu is not implemented in the HTML component itself. If the client wishes to provide this functionality, they can listen for a right mouse button down event, display their own menu, and use the menu select information with the IndicatedElement property to perform any requested function.Document History and Navigation
Also note that this bean doesn't directly support a history list or forward/back behavior. That functionality may be provided by the client, or by using the HotJava Document Stack.Introspection
A BeanInfo class, HotJavaBrowserBeanBeanInfo, explicitly provides information for properties, events, and methods.Customization
Rather than providing a BeanCustomizer class, the relevant state of the HTML component may be accessed through the use of the HotJava System State bean.
| CurrentDocument | currentDocument | [constrained][bound] | - the document being displayed | (rw) |
| String | documentString | [bound] | - the URL for the current document as a string | (rw) |
| URL | documentURL | [bound] | - the URL for the current document | (rw) |
| Reader | documentSource | [bound] | - the input stream for the current document | (rw) |
| String | documentTitle | [bound] | - the title of the current document | (ro) |
| String | errorMessage | [bound] | - the most recent error | (ro) |
| String | statusMessage | [bound] | - the latest status | (ro) |
| double | loadingProgress | [bound] | - progress information during document loading | (ro) |
| boolean | documentReloadable | [bound] | - true when the document can be reloaded | (ro) |
| boolean | secureConnection | [bound] | - true when the current connection is secure | (ro) |
| String[] | frameList | [bound] indexed | - the names of all HTML frames | (ro) |
| DocumentSelection | selection | [bound] | - the user's current selection | (ro) |
| ElementInfo | indicatedElement | [bound] | - the link (if any) under the cursor | (ro) |
| String | charset | [bound] | - character set used to translate into Unicode | (rw) |
| instantiation | HotJavaBrowserBean()
clone() |
| control | find()
print() (2) clearImageCache() executeHistoryCommand() reload() stopLoading() start() stop() |
| accessing the document | getCurrentDocument()
setCurrentDocument() getDocumentString() setDocumentString() getDocumentURL() setDocumentURL() getDocumentSource() setDocumentSource() |
| reading status | getDocumentTitle()
getErrorMessage() getStatusMessage() getLoadingProgress() getSelection() getIndicatedElement() isDocumentReloadable() isSecureConnection() |
| accessing frames | getFrameList() (2) |
| accessing character set | getCharset()
setCharset() |
| adding/removing listeners | addBrowserHistoryListener()
removeBrowserHistoryListener() addPropertyChangeListener() removePropertyChangeListener() addVetoableChangeListener() removeVetoableChangeListener() |
As Listener
EventListener Interfaces: BrowserHistoryListener
PropertyChangeListener
VetoableChangeListener
EventListener Interfaces: BrowserHistoryListener
ComponentListener
Most events are either pre-notifications of property change with the option for the listener to veto (constrained), or post-notifcations of property change (bound). Listeners may register for pre-notification of constrained properties with addVetoableChangeListener() and/or post-notifcation of bound properties with addPropertyChangeListener().As ListenerCommunication with the HotJava Document Stack is handled by means of the BrowserHistoryListener interface. Messages of the form executeHistoryCommand() are sent to the document stack to notify of changes in the current document state or to clear the history.
EventListener Interfaces: BrowserHistoryListener
PropertyChangeListener
VetoableChangeListenerEventObjects: BrowserHistoryEvent
PropertyChangeEvent
The HotJava Document Stack also sends the executeHistoryCommand() method to update the HTML component as "next" and "previous" operations are performed. Hence, this component is also a BrowserHistoryListener.This component is also intended to be the target of button pushed and other component activation, and therefore implements ComponentListener.
EventListener Interfaces: BrowserHistoryListener
ComponentListenerEventObjects: BrowserHistoryEvent
class CurrentDocument {
public String documentString; // String rep of URL
public URL documentURL; // URL
public String frameName; // Frame document is displayed in
public boolean externalHint; // A hint given if the HTML component thinks
// the client should veto the change, and
// set this property on a new bean instance,
// or an existing instance that contains
// the named frame
};
class Cookie {
public int version; // Cookie version
public String attribute; // Attribute name
public String value; // Value
public String domain; // Domain
public String path; // Path
public String comment;
public Date expires; // Exipration date
public boolean secure; // Is this a secure cookie?
public static Cookie parseFromString( String cookieString );
public static Cookie[] parseFromString( String cookieString );
public static String[] combineAsStrings( Cookie[] cookieList );
public String toString(); // Convert to string.
};
class CookieJar {
public CookieJar(Cookie[]);
public Cookie[] getCookies();
public boolean isIncrementalChange(CookieJar other);
public Cookie entryAdded(CookieJar other);
public Cookie entryRemoved(CookieJar other);
};
class PoolEntry {
public String url; // URL string of entry
public Date lastTouched; // Expiration date of entry
public String URL; // URL string of entry
};
class URLPool {
public URLPool(PoolEntry[]);
public PoolEntry[] Entries();
public boolean isIncrementalChange(URLPool other);
public PoolEntry entryAdded(URLPool other);
public PoolEntry entryRemoved(URLPool other);
};
class DocumentSelection {
public String text; // Text of selection
public String html; // HTML of selection
};
class ElementInfo {
public String imageURL; // Image link
public String hrefURL; // HREF link
public String altText; // Alt text
public MouseEvent event; // source event
};
class SystemProperties {
public SystemProperties(Hashtable values)
public Hashtable getValues()
}
HotJava Browser Components
HotJava Authenticator Bean
HotJava Document Stack Bean
HotJava System State Bean
DelegatingSecurityManager