We will use the classical Hello world as the first simple example
of an extension. This extension will add a new menu item in the
menu which displays a popup with the text "Hello world!" when
selected. Copy the XML code below and save it to a file in
directory. The filename must end with
If you have enabled automatic installation just wait a few seconds and the
extension will be installed automatically. Otherwise you may have to do a manual scan:
( → ).
You may have to logout and login again to see the new menu item.
<extensions> tag is the root
tag and is needed to set up the namespace and schema validation.
<extension> defines a new
extension. It must have an
id attribute that
is unique among all installed extensions and an
attribute which id the ID of the extension point. For the
attribute we recommend using the same naming conventions as for java
packages. See Java naming
conventions from Sun.
<about> tag is optional and
can be used to provide meta information about the extension. We
recommend that all extensions are given at least a
<name>. Other supported subtags are:
|Global about tag|
<action-factory> tag is required and
so is the
<factory-class> subtag. It tells
the extension system which factory to use for creating actions. The
is a very simple factory that is shipped with BASE. This factory always creates the same
menu item, no matter what. Another factory for menu items is the
which can create menu items that depends on the logged in user's permissions. It is
for example, possible to hide or disable the menu item if the user doesn't have enough
permissions. If none of the supplied factories suits you it is possible to
supply your own implementation. More about this later.
<parameters> subtag is used to
provide initialisation parameters to the factory. Different factories
supports different parameters and you will have to check the javadoc documentation
for each factory to get information about which parameters that are supported.
In case the factory is poorly documented you can always assume that public
methods the start with
A single extension can extend multiple extension points as long as their
action classes are compatible. This is for, for example, the case when
you want to add a button to more than one toolbar.
To do this use the
tag with multiple
You can skip the
attribute in the main tag.
<extension id="net.sf.basedb.clients.web.menu.extensions.history-edit" > <extends> <ref index="2">net.sf.basedb.clients.web.tabcontrol.edit.sample</ref> <ref index="2">net.sf.basedb.clients.web.tabcontrol.edit.extract</ref> </extends> ... </extension>
This is a feature of the XML format only. Behind the scenes two extensions will be created (one for each extension point). The extensions will share the same action and renderer factory instances. Since the id for an extension must be unique a new id will be generated by combining the original id with the parts of the id's from the extension points.