HTML Component

The rapid growth of HTML as a basic application platform makes displaying web content a topical question for many developers and designers, whether this content is various web sites or static HTML pages. Therefore, the need has arisen to create a reusable HTML component that can be repeatedly used by different applications and modified according to current business needs. The Java™ platform enables all functionalities to create such cross-platform encapsulation.

The HTML component provides a web viewer and full browsing functionality through its API. In particular, it supports events handling, for example, load progress, or URL traversed. The current implementation of the HTML component supports so called "street HTML", an HTML syntax which does not meet all requirements of the HTML specification, however, it is recognized by major world known browsers. Moreover, the component is implemented as lightweight in order to avoid allocating native resources in the operating system's windowing toolkit, and easy integrating with Java and JavaFX graphics libraries. The HTML component is based on WebKit, an open source web browser engine, which supports HTML4, CSS, JavaScript, DOM, SVG.

When designing an embedded browser instance, the following features are typically considered:

  • Accessing certain domains
  • Accessing the local file system
  • Loading a URL
  • Moving forward or backward in the browser's history
  • Printing web page
  • Reloading the current web page
  • Stopping loading the web page in progress
  • Support for JavaScript and plugins
Due to these features, the embedded browser enables you to host web pages and other browser-enabled documents in your applications.

The following structure depicts the internal architecture of the embedded browser.

internal structure

Figure 1. The HTML component architecture

The JWebPane component provides basic web page browsing functionality. It renders web pages and provides basic user interaction, such as navigating links, and submitting HTML forms. The JWebPane component displays one web page at a time. The PolicyDelegate is intended for implementing a browser policy. Implementations may use arbitrary logic to enable or reject sensitive operations such as loading web pages, opening new browser windows or running scripts on pages. An implementation may thus act as a list-based URL filter or a popup blocker. A single PolicyDelegate may be associated with a JWebPane object. It then receives notifications from the JWebPane about changes to the browser state that are about to happen. The PolicyDelegate may either accept or reject these changes. The LoadStateListener tracks the state of a page load.

At the moment the project is 70% complete. The JWebPane component implemented as a lightweight component extending the JComponent class, which enables easy embedding into an application UI context. Moreover, the JWebPane component may contain several web frames with the specified icon, title, and URL. The following browsing features are available:

  • Loading control — load, stop, and reload functions.
  • Listeners handling. — typical function enabling a developer to get, add, and remove listeners.
  • JavaScript support
The current implementation of the embedded browser supports handling of the following events:
  • Page loading started
  • HTTP server redirection processed
  • Icon for the page received
  • Page title received
  • Page content loaded completely
  • An image contained in the page loaded
  • Page and all its resources loaded completely
  • Loading Failed
In spite of limited functionality, the embedded browser can be successfully employed in Rich Internet Application. The following figure shows a simple JavaFX application, where the HTML component has been embedded into the frame and rotated using the scene graph functionally. Note that the embedded browser possesses all the declared capabilities. The page is live! If you right click the hyperlink, the pop up menu appears.

HTML component demo screen shot

Figure 2. The HTML component embedded into the JavaFX application Click the image to view it at its natural size.

The following new features are scheduled to be implemented by August'08:

  • Viewing the History, including Back and Forward functions.
  • Notifications of external resources loading
  • Progress status
  • Viewing page source
To put it briefly with the HTML component developers can substantially extend the capabilities of desktop applications, thereby enabling all commonly used browsing features and easily retrieving functionality of the embedded lightweight component. Find more information about the JWebPane component in the Artem Ananiev's Blog.

-- Alla Redko

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Blog about Java technology documentation and news about Java releases.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today