Lets say your old granny complains about her stupid browser and asks you to implement the following: Whenever the mousepointer is over a link to a page she has visited before, the title of this page should be displayed in the browser's statusbar.
This is an example how granny wants her browser. She hates URLs:
This simple task normally includes a lot of complicated programming but do not worry: It is fairly easy with Scone. We will first have a look at a HtmlTokenEditor (the code that works on the Html documents), then we will setup a plugin for Scone in order to use our HtmlTokenEditor and finally we will perform some nice finetuning.
An HtmlTokenEditor is an object which is plugged into the datastream from a webserver to your browser. Usually you don't want to anaylze an Html document bytewise so Scone parses the byte stream for you and provides you with nice clean Html tokens.
|The treatment of LinkTokens|
To understand this piece of code we have to cast a look at how Scone sees the Internet: The Scone framework automatically analyzes incoming Html documents and stores some of their entities as objects. An HtmlNode for example contains information about an Html document, a NetNode is a resource within the Internet and a Link is a link from one NetNode to another one. There are many more object types and they are all persistent within the Scone framework and accessible through their caches (for performance reasons). To understand the line
HtmlNode doc=HtmlNodeCache.check(linkToken.getLink().getToNode());we split it:
A LinkToken contains not only a tag which defines a link, but also a Link object.
linkToken.getLink()returns this Link object. A Link object basically contains references to two NetNode objects and the method
getToNode()returns the Node which is linked to. Knowing the NetNode object of the page that is linked to we know its URI but not its title. If the page belonging to this NetNode has been loaded through Scone before, there must be an HtmlNode which we receive through the HtmlNodeCache.
HtmlNodeCache.check(NetNode node)returns this HtmlNode if it exists or null otherwise. A long way to go but now we have our HtmlNode and
doc.getTitle()simply returns the title of our page (if specified).
linkToken.setParam("onMouseOver",jsEvent);now adds an attribute to the link tag and we are done! This code will transform a tag like this
<A HREF="manual/">to a tag like this
<A HREF="manual/" onMouseOut="status='';return true;" onMouseOver="status='Apache 1.3 documentation ';return true">
And here's a simple plugin for our StatusBarWizard:
The requirements tell Scone which features have to be available at runtime. We need the information from the HtmlNode objects and the PARSEDOCUMENT feature creates these objects. The CONSIDERLINKS feature creates the LinkToken and Link objects.
In the init() method we setup our "wizard". The String "StatusBarWizard" is helpful for debugging, HTDOCCONDITION specifies that only real Html documents should be edited by StatusBarWizard and 60 is a priority in case two or more HtmlTokenEditors run under the same conditions.
This plugin can now be registered with
runscone -register StatusBarWizardPluginand we are done :-)
Of course there is still a lot of room for improvement, the browser caches the Html documents and so
there is not always the newest information displayed in the status bar. But nothing is impossible...
You are using Scone and so there is an easy way to do this. Just add
Our plugin inherits the method
getProperties() which returns a PersistentProperties object. This object
automatically corresponds to the properties set in a file called
This file could look like this:
To make these properties accessible in StatusBarWizard, we write a constructor for it where we pass on the plugin object and store it locally in a variable "plugin". Then we can add these lines in handleRequest():
The Scone configuration GUI will now automatically render a properties configuration dialog:
Voilą! We have our reliable futuristic configurable plugin :-)
For more Information please contact Volkert Buchmann
Last Update: 3-Aug-2002