blob: c8bc8c20ba1eb0d4c873604822483e41467bf5db [file] [log] [blame]
h1. Extending Webconsole
Webconsole extensions may be done by different ways. In this section we going to cover followin topic - new pages, new navigation elements and new widgets.
h2. New pages
Webconsole ships four different types of pages which should be used in different cases.
* BasePage
* SecuredPage
* SinglePage
* SidebarPage
h3. BasePage
BasePage is used to load shared resources and keep same look and feel on all webconsole pages. You should use this page for non-secured operations for example to build your own LoginPage and so on.
h3. SecuredPage
SecuredPage will be rendered to users which have 'admin' role assigned. Others will see error page. By default this page renders navigation bar and adds logout link.
h3. SinglePage
SinglePage is secured. If you have no additional navigation or your content requires full screen width then use this page. You will have all screen to display data.
h3. SidebarPage
SidebarPage is secured. If you have additional navigation then Sidebar is what you need. In your extension you have to call *setSidebarProvider* method othervise your sidebar won't be displayed.
h2. New navigation elements
When you implement own modules you honestly want to add new tab or new link somewhere to let user navigate directly to your logic without address bar usage.
To do this we shipped a *ConsoleTabProvider* interface. Just register an implementation of it under OSGi as a service and when webconsole will be ready to serve content it will ask your service for module home link and sub items.
h2. Widgets
Every management tool requires widgets. ;) We know about this and we provided also a *WidgetProvider* interface. It works in same way as a ConsoleTabProvider but it doesn't return links - it returns panels. Please remember following rule - because widgets may be used in different places you need to directly specify your widget provider 'intention'. Webconsole uses 'intention' service property to group providers. Please take a look for example below:
{code:xml}
<?xml version="1.0" encoding="utf-8" ?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<service ref="widgetProvider" interface="org.apache.karaf.webconsole.core.widget.WidgetProvider">
<service-properties>
<entry key="intention" value="dashboard" />
</service-properties>
</service>
<bean id="widgetProvider" class="com.example.extension.MyWidgetProvider" />
</blueprint>
{code}
Widgets created by MyWidgetProvider will be used in dashboard.