The BASE application includes an extensions mechanism that makes it possible to dynamically add functions to the GUI without having to edit the JSP code. It is, for example, possible to add menu items in the menu and toolbar buttons in selected toolbars.
Go to the Chapter 22, Plug-ins and extensions.
menu to display a list of possible extension points and all installed extensions. From this page, if you are logged in with enough permissions, it is also possible to configure the extensions system, enable/disable extensions, etc. Read more about this inExtensions can come in two forms, either as an XML file in the BASE Extensions XML format or as a JAR file. A JAR file is required when the extension needs to execute custom-made code or use custom resources such as icons, css stylesheets, or JSP files.
The code examples in this chapter can be downloaded from the BASE plug-ins site: https://baseplugins.thep.lu.se/wiki/net.sf.basedb.examplecode
An extensions point is a place in the BASE core or web client interface
where it is possible to extend the functionality with custom extensions. An
extension point has an ID which must be unique among all existing
extension points. Extension points registered by the BASE web client all
starts with net.sf.basedb.clients.web
prefix. The
extension point also defines an
Action
subclass that all extensions must implement.
An extensions is a custom addition to the BASE web client
interface or core API. This can mean a new menu item in the menu or a
new button in a toolbar. An extension must provide an
ActionFactory
that knows how to create actions that fits the requirements
from the extension point the extension is extending.
An Action
is an interface definition which provides an extension point enough
information to make it possible to render the action as HTML.
An action typically has methods such as, getTitle()
,
getIcon()
and getOnClick()
.
An ActionFactory
is an object that knows how to create actions of some specific type, for
example menu item actions. Action factories are part of an
extension definition and can usually be configured with parameters
from the XML file. BASE ships with several implementations of
action factories for all defined extension points. Still, if your
extension needs a different implementation you can easily create your
own factory.
A Renderer
is an object that knows how to convert the information in an action to
HTML. The use of renderers are optional. Some extension points use a
"hard-coded" approach that renders the actions directly on the JSP file.
Some extension points uses a locked renderer, while other extension
points provides a default renderer, but allows extensions to supply their
own if they want to. Renderers are mostly used by the web client extensions,
not so much by the core extensions.
A RendererFactory
is an object that knows how to create renderers. Renderer factories can
be part of both extension points and extensions. In most other aspects
renderer factories are very similar to action factories.
An ErrorHandlerFactory
is an object that knows how to handle error that occur when executing extensions.
An error handler factory is defined as part of an extension point and handles all
errors related to the extensions of that extension point. In most other aspects
error handler factories are similar to renderer and action factories. If the
extension point doesn't define an error handler factory, the system will
select a default that only writes a message to the log file
LoggingErrorHandlerFactory
A ClientContext
is an object which contains information about the current user session.
It is for example, possible to get information about the logged in
user, the currently active item, etc.
In the BASE web client the context is always a
JspContext
.
Wherever a ClientContext
object is provided as a
parameter it is always safe to cast it to a JspContext
object. Extension points in the core usually use a
ClientContext
.
The context can also be used by an extension to request that a specific javascript or stylesheet file should be included in the HTML code.