Use Cases

JWebEngine can be used in a variety of scenarios that even we might not be aware of. Nevertheless we want to show you what we've come up with. Both of our outstanding products, i-net Clear Reports and i-net HelpDesk (german), already leverage from JWebEngine. Use these ideas and try out yourself.

HTML Viewer / Renderer

other-products:jwebengine:acid-1-test.pngother-products:jwebengine:mail-acid-test.png

Using JWebEngine as HMTL Viewer ist probably the most common scenario. Bind the library to a JEditorPane or JTextPane and hand in the URL you want to display.

You can use this as starting point for e.g. Java Help systems, email clients or even a custom browser software. Since HTML makes more sense with page interlinks - or even download links - or your own custom links e.g. for a file open dialog - JWebEngine supports custom link handler.

The previous two images have been rendered with a version of JWebEngine. Click on them to see a larger version. Take a look at the following sample (it's a JNLP and will download itself to your computer).

Start download of the Render Example

HTML Editor

other-products:jwebengine:sourcecode.png

An outstanding feature of JWebEngine is the WYSIWYG editing capability besides the pure HTML rendering. Combined viewing and editing of HTML documents pushes JWebEngine even more into the position as adequate email client displaying and writing component.

The following sample shows an file editing dialog (click to download the JNLP).

JWebEngine comes with a formatting toolbar and a source code view - both can be disabled programmatically. You can even add a spell checking tool like JOrtho.

Start download of the Editor Example

Browser

Using JWebEngine within a browser is obviously a subset of the HTML Viewer, but it stands aside for us because we know that JWebEngine is not a perfect browser engine at all.

You can clearly use JWebEngine as rendering backend for something that has an URL input field, tabbed browsing, previous and next buttons - but todays browser standards are much higher. We think that e.g. JavaScript could be added to some extend and even CSS2/3 are on our list of future enhancements. But up to this point this is just a possible but not a perfectly supported scenario.

Java Help

Java Help originally is based upon Suns internal renderer. JWebEngine is a perfect substitute renderer for in this case. It supports way more standard layout methods like floats and absolute position. This enables you to create fancy help pages despite the poor HTML render quality of the original Java Help.

If you want to see this use case in action, have a look at the i-net Designer help pages. The code below is an example on how to set JWebEngine as renderer for Java Help by adjusting the HelpSet in the XML of JavaHelp.

<impl>
    <helpsetregistry helpbrokerclass="javax.help.DefaultHelpBroker" />
    <viewerregistry viewertype="text/html" viewerclass="com.inet.html.InetHtmlEditorKit" />
</impl>

Template Editor

JWebEngine has a somewhat open API allowing to create custom tags, their representation and meaning. Using the following code example you can easily create a placeholder for later replacements. The scenario perfectly fits into template and signature editors or into mail series.

Simply bind a tag to a view representation

public class PlaceholderFactory extends InetHtmlFactory implements ViewFactory {
    ...
    @Override
    public View create( Element elem ) {
        Object tag = elem.getAttributes().getAttribute( StyleConstants.NameAttribute );
        if( tag instanceof String && "placeholder".equalsIgnoreCase( (String)tag )){
            return new PlaceholderView( elem, elem.getAttributes().getAttribute( "localname" ) );
        }
    }
}

and define on your own, how these elements should be displayed

public class PlaceholderView extends ContentView {
    ...
    public PlaceholderView( Element elem, String localName ) {
    ...
    @Override
    protected String getText() {
        return "{" + localName + "}";
    }
}

CSS Inliner

Ever wondered how to submit a nicely layout website with linked CSS as single page single page? There is a CSS Inlining function right in JWebEngine.

This may be the only way to have a standalone CSS rich HTML page embedded in another one. Since HTML is designed to have the style definition in the head section, newly added HTML cannot redeclare style tags (though some browser do understand that, while others don't).

Inlined CSS is a way that our very own product documentation is being brought into i-net Clear Reports‘s remote interface. Users can now see the docs as standalone version from their harddisk and we do not have to provide another version for the remote interface.

HtmlConverter.html2inlinedHtml( ... )
 

© Copyright 1996 - 2024, i-net software; All Rights Reserved.