-
Notifications
You must be signed in to change notification settings - Fork 6
Creating addins
Add-ins are located on the right-hand side of the layout. Which add-ins are displayed can be defined by each user together with their order of appearance under Customization.

AddinModules are considerably simpler than operations or tabs since they are in first instance independent of domain classes. Like all content modules they have to be placed under grails-app/modules. They need to provide a class implementing the interface AddinModule, as well as a view template to render. The view template should begin with an underscore and be located under grails-app/views/addins. Let's look at an example:
package org.openlab.module.addin
import org.openlab.module.*;
class GeneLegendAddinModule implements AddinModule{
//the name of the add-in will be displayed for selection in the user settings
def getName()
{
"gene legend"
}
//the name of the template
def getTemplate()
{
"geneLegendAddin"
}
//the name of the grails-plug-in corresponding to the OLF module
//used for locating the template
def getPluginName()
{
"gene-tracker"
}
}Add-ins are displayed independent of the domain object is currently displayed in the main panel. However, it might be cool to adapt the content of the add-in flexibly depending on what the user can see in the main panel. Such dynamic interactions are easily possible on the java-script level of the application thanks to a messaging system. An example: The barcode add-in displays a field where a barcode can be entered. If a user switches to a domain object that is known to be "printable" (see Barcode-module#supported-types), it will switch to a printing view template. This is achieved using the aforementioned messaging system together with a remote Ajax call:
<div id="barcodeCreator"/>
<script type="text/javascript">
var updateBarcodeAddin = function (type, args, me) {
${remoteFunction(params: "\'name=\'+args[0]+\'&className=\'+args[1]+\'&id=\'+args[2]", controller:"barcode", action:"renderBarcodeCreator", update:[success: "barcodeCreator", failure: "barcodeCreator"])}
};
olfEvHandler.bodyContentChangedEvent.subscribe(updateBarcodeAddin, this);
</script>