Job Title: Software Developer, IBM Case Manager Client Company: IBM
Job Title: Software Developer, IBM Case Manager Client Company: IBM
Job Title: Software Developer, IBM Case Manager Client Company: IBM
Contributor: Wang, Qi
Job Title: Software developer, IBM Case Manager Client
Email: wangqqi@cn.ibm.com
Company: IBM
Introduction
You can customize Case Manager Client by creating your own page widgets. In addition,
you can customize the page widgets that are provided by IBM Case Manager to tailor
them to your needs.
Audience
This tutorial is intended for developers who create Case Manager Client applications and
for business analysts who design case management solutions.
Prerequisites
Before you begin this tutorial, you should be familiar with the programming model for
Case Manager Client. For an overview of this model, see the developerWorks article
Introduction to the IBM Case Manager JavaScript API.
You should also be familiar with the concepts and programming models that are used to
build plug-ins for IBM Content Navigator. For more information, see Developing
applications with IBM Content Navigator in the IBM FileNet P8 Version 5.2 Information
Center.
To develop a widget, you must know how to use the following technologies:
Name Description
Creating custom widgets with the IBM Case Manager JavaScript API Page 2 of 36
developerWorks® ibm.com/developerWorks/
Name Description
Name Description
Creating custom widgets with the IBM Case Manager JavaScript API Page 3 of 36
developerWorks® ibm.com/developerWorks/
These two features allow the Business Analyst to dynamically adjust page and widget
behavior with little to none programming skills.
The following guidelines should be kept in mind when creating a Page widget:
UI dijit
First create a normal Dojo dijit which is responsible for rendering the user
interface and handling user interaction to collect user input.
Ideally, this dijit should be a designed as a reusable component that takes in a
context and renders itself.
The UI dijit should not access any IBM Case Manager Page Container related
APIs, which will limit its usage to only the IBM Case Manager Case Client.
Separating the UI dijit from the Page widget layer will allow you to reuse this dijit
in a custom application or plug-in built on top of IBM Content Navigator.
The dijit could also be reused in a non-ECM environment if it doesn’t use any
ECM related API.
The dijit should also expose necessary dojo methods/events to allow interested
parties (the page widget wrapper or other custom widgets) to exchange data or get
notified by user interaction.
Page widget
After the dijit corresponding to the user interface is ready, you will need to create
a Page widget wrapper that extends this UI dijit and converts it into an IBM Case
Manager Page widget.
The page widget wrapper should be the place where the page container related
code resides.
The page widget wrapper accepts widget settings from the page container and
passes them to the underlying dijit.
It should also connect to Dojo events exposed on the dijit to be notified of user
actions.
Creating custom widgets with the IBM Case Manager JavaScript API Page 4 of 36
developerWorks® ibm.com/developerWorks/
Terms of use
When developing or extending custom widgets in IBM Case Manager, avoid referencing
the IBM Case Manager Case Client JavaScript code base directly or copying the Case
Client JavaScript code. It is recommended to follow the IBM Case Manager JavaScript
API and utilize public functions there. Private functions from the IBM Case Manager
Case Client code can change between releases and will cause maintainability and
functionality issues for your custom widgets.
When using public functions in your custom widgets, you can create your custom widget
as a subclass to the IBM Case Manager out of the box page widgets. Only public methods
can be overwritten within the subclass and as needed, call the parent class inherited
function accordingly. You may overwrite the the method if full customization is needed.
In this step, you create a web project for the custom page widget and actions. The
web project defines the folder structure that is required for building, packaging
and registering your custom widget package.
In this step, you create the files that are needed to register the page widgets and
make them available for use in Case Manager Builder.
In this step, you create the classes and files that are needed to use your custom
page widgets in Case Manager Client, which runs in IBM Content Navigator.
These files also make any custom actions available in Case Manager Builder,
Case Manager Client, and IBM Content Navigator.
4. Implement the custom page widgets and any custom actions that are used by the
widgets.
Creating custom widgets with the IBM Case Manager JavaScript API Page 5 of 36
developerWorks® ibm.com/developerWorks/
In this step, you create the JavaScript files that implement the functions
performed by your custom page widgets and actions.
In this step, you create a package that contains the files that are required to deploy
your custom widgets.
In this step you use the IBM Case Manager configuration tool to deploy your
custom widget package
In this step, you add the custom page widgets and actions into a page in Page
Designer.
In this step, you save the page and deploy the solution in Case Manager Client.
In this step, you open your solution and work with your custom widgets to
determine if changes are needed.
Creating custom widgets with the IBM Case Manager JavaScript API Page 6 of 36
developerWorks® ibm.com/developerWorks/
For the sample custom widget package, the project and folder structure will be as
follows:
Creating custom widgets with the IBM Case Manager JavaScript API Page 7 of 36
developerWorks® ibm.com/developerWorks/
The registry files are created in the folder using the following structure:
Creating custom widgets with the IBM Case Manager JavaScript API Page 8 of 36
developerWorks® ibm.com/developerWorks/
Required
Property or Option- Type Description
al
Name Required String The name for your custom page widget
package. You must specify a unique name
for the package to avoid overriding an
existing page widget package.
Description Required String A description of the custom page widget
package.
Locale Required String The code that identifies the locale for the
current catalog.
CaseWidgets
GenericWidgets
For example, the Catalog.json file for the sample custom widget package contains
the following package properties:
2. For each page widget in the package, enter the following properties:
Creating custom widgets with the IBM Case Manager JavaScript API Page 9 of 36
developerWorks® ibm.com/developerWorks/
Tip: Except for the definition property, these properties are identical to the
properties in the widget definition file. For consistency, you can copy the values
from that file into the Catalog.json file. If a value does not match, IBM Case
Manager uses the value from the Catalog.json file.
Required
Property or Op- Type Description
tional
id Required String A unique identifier for the page widget.
category Required String The identifier of the category in which
the page widget is to be listed in Case
Manager Builder.
title Required String The name to be displayed for the page
widget in Case Manager Builder.
description Required String A description of the page widget.
definition Required String The full path and name of the definition
file for the page widget.
preview Required String The relative path and name of the re-
source file that contains the preview im-
age for the page widget.
Creating custom widgets with the IBM Case Manager JavaScript API Page 10 of 36
developerWorks® ibm.com/developerWorks/
Required
Property or Op- Type Description
tional
properties Required Array An array that defines the properties that
can be set for the page widget in Case
Manager Builder.
events Required Array An array that identifies the events that the
page widget publishes and subscribes to.
For example, the Catalog.json file for the sample custom widget package contains
the following properties for the Custom Case Information widget:
You create a JSON definition file to define the properties and events for the page widget.
1. For each page widget in the package, enter the following properties:
Tip: These values are also used for the page widget in the Catalog.json file. For
consistency, you can copy the values from this file into the Catalog.json file. If a
value does not match, IBM Case Manager uses the value from the Catalog.json
file.
Re-
quired
Property Type Description
or Op-
tional
id Required String A unique identifier for the page widget.
category Required String The identifier of the category in which the
page widget is to be listed in Case Manager
Builder.
title Required String The name to be displayed for the page wid-
get in Case Manager Builder.
description Required String A description of the page widget.
Creating custom widgets with the IBM Case Manager JavaScript API Page 11 of 36
developerWorks® ibm.com/developerWorks/
Re-
quired
Property Type Description
or Op-
tional
preview Required String The relative path and name of the resource
file that contains the preview image for the
page widget.
2. Define the properties that can be set for the page widget when the user adds the
widget to a page. These properties include the toolbars, menus, and actions that
can be added to the widget.
3. Define the events that the page widget subscribes to and publishes. For each
event, provide the following properties:
Creating custom widgets with the IBM Case Manager JavaScript API Page 12 of 36
developerWorks® ibm.com/developerWorks/
Property Description
title The title that is displayed in the Wiring dialog box for the
event.
functionName For an event that the page widget subscribes to, the name
of the function that handles the event.
type For an event that the page widget publishes, the type of
event. Set the type to Broadcast if the widget broadcasts
the event to other widgets on the page. Set the type to
Wiring if the event must be wired to another widget on the
page.
For example, the CommentWidget.json file contains the following events for the
Comment Page Widget:
Using an IBM Content Navigator Plug-in is the standard way to extend the base function
of the product. By building a custom plug-in, you can add widgets, actions, and services
to IBM Content Navigator.
To create the plug-in package, you combine the classes and JavaScript files into a JAR
file. The following graphic shows the JAR file that contains the directories and files that
are needed for the custom page widget and actions:
Creating custom widgets with the IBM Case Manager JavaScript API Page 13 of 36
developerWorks® ibm.com/developerWorks/
The CustomPlugin.class describes the custom plug-in. The class provides the initial JS
file name for the plug-in, as well as the action list provided by the package.
To declare the plug-in class to IBM Content Navigator, add the plug-in class to the
META-INF\MANIFEST.MF as follows:
The WebContent\[Custom Plugin].js file registers the Dojo module path for the custom
runtime code. Depending on whether debug mode is on or off, the [Custom Plugin].js file
can load in the source code for debugging or in the combined and compressed code for
better performance.
Each custom action class in the actions folder also provides an action definition.
JavaScript file
The initial JavaScript file for the sample plug-in is ICMCustomPlugin.js. You can use the
getScript() method to get this file. This JavaScript file performs the following steps to
bootstrap the custom widget at runtime:
1. Load the CSS files used by the custom runtime code for the page widget and
action.
Creating custom widgets with the IBM Case Manager JavaScript API Page 14 of 36
developerWorks® ibm.com/developerWorks/
2. Register the Dojo module path icm/custom for the custom runtime code.
ICM Content Navigator loads and evaluates the plug-in JavaScript file before the user
sees the login page.
If you want to combine the JavaScript code to improve performance, consider whether
you need to use debug mode. (The mode is also applicable to IBM Case Manager.) To
run in debug mode, set the parameter debug=true is set in the URL. In this mode, the
JavaScript file requires the minimum runtime Dojo modules that are necessary to
bootstrap the custom code. If you run in non-debug mode, the JavaScript loads the entire
set of compressed custom runtime code.
Custom actions
The custom IBM Case Manager actions list contains the PluginAction instances that
define client-side actions provided by this plug-in. You can get this list by using the
getActions() method.
The IBM Content Navigator action definition is exposed through the action Java class,
providing action definitions such as the action ID, icon, and the action model class. IBM
Case Manager action definitions are IBM Content Navigator actions that have been
extended. The actions have additional definition information exposed through the
getAdditionalConfiguration() method.
The getActions() method returns a JSON string, which enables the Page Designer to use
the JSON definition and show actions in the page widget menu setting.
The first action is the CustomAddCaseAction. The following example shows the JSON
definition of the action:
The JSON definition is used by Page Designer to build the configuration panel of the
action.
When you design a page and add the Add Custom Case action to the toolbar, the
following configuration pane for the action displays:
Creating custom widgets with the IBM Case Manager JavaScript API Page 15 of 36
developerWorks® ibm.com/developerWorks/
You can create a button label for the action, for example, Launch Fraud Investigation
Case, which can later be localized for different languages. You can also enter the solution
ID and Case Type for the runtime code to access.
In addition, the Open Add custom Case Page event published by the action is exposed
through the page widget that hosts the event. For example, after you add the action to the
toolbar page widget, the event displays in the toolbar page widget’s event wiring dialog.
You can wire the event to the page container’s Add Case event handler for opening the
Add Case page.
Creating custom widgets with the IBM Case Manager JavaScript API Page 16 of 36
developerWorks® ibm.com/developerWorks/
This action does not have additional configuration items. It can publish the "Add
document as attachment" event which includes the attachment id and the selected
document model object in payload. Then, you can wire the action to the Attachment page
widget event handler to enable adding the selected document as an attachment.
1. Create a JAR file that contains the files that are used for the plug-in.
packageName
Creating custom widgets with the IBM Case Manager JavaScript API Page 17 of 36
developerWorks® ibm.com/developerWorks/
// Include all the Java classes that extend the Plugin class
and
// any other Java classes that are required by the plug-in
Java class 1
Java class 2
...
WebContent
// Include all the image, JavaScript, and HTML files
// that are required by the plug-in
WEB-INF
manifest.mf
In the packageName folder, include the Java™ class files that are defined for the
plug-in. Create the subfolders based on the package names of the Java classes.
Follow the standard JAR file structure by using nested folders for nested
packages.
Important: All the Java classes must be included in a named package. You cannot
use the default package.
2. Modify the manifest.mf file for your plug-in to include the following property:
Plugin-Class: pluginClassName
You can also include any of the standard properties for a JAR file in the mani-
fest.mf file.
Important: The plug-in JAR file must be available on a URL addressable web ap-
plication server or the plug-in will not work in the web client.
4. Use the IBM Content Navigator administration desktop to add the new plug-in.
The following graphic shows the recommended structure for a page widget:
Creating custom widgets with the IBM Case Manager JavaScript API Page 18 of 36
developerWorks® ibm.com/developerWorks/
In this graphic, the classes in the black box implement the user interface for the page
widget and handle the user's interaction with the interface.
The classes in the red box are base IBM Case Manager classes from which the custom
page widget inherits functionality. The icm.base._BaseWidget class, which provides
functions that display the widget description and show or hide the content pane.
The class in the blue box is the base class for any page widget that hosts a toolbar or a
pop-up menu.
1. Create a JavaScript file that implements the WidgetContentPane class that is used
to draw the user interface for the CustomPageWidget widget. This class:
Creating custom widgets with the IBM Case Manager JavaScript API Page 19 of 36
developerWorks® ibm.com/developerWorks/
Creating custom widgets with the IBM Case Manager JavaScript API Page 20 of 36
developerWorks® ibm.com/developerWorks/
<target name="clean">
<delete>
<fileset dir=".">
<include name="*.jar" />
</fileset>
</delete>
</target>
<target name="buildPlugin">
<javac destdir="./bin" srcdir="./src" debug="on">
<classpath>
<pathelement location="./lib/nexus.jar" />
</classpath>
</javac>
<copy todir="./bin" overwrite="yes">
<fileset dir="./src">
<include
name="com/ibm/icm/extension/custom/WebContent/**/*.*" />
</fileset>
</copy>
<jar destfile="./ICMCustomPlugin.jar" manifest="./src/META-
INF/MANIFEST.MF" update="true">
<fileset dir="./bin">
<include name="**/*.*" />
</fileset>
</jar>
</target>
<target name="clean">
<delete>
<fileset dir=".">
<include name="*.war" />
<include name="*.ear" />
</fileset>
</delete>
</target>
<target name="createWAR">
Creating custom widgets with the IBM Case Manager JavaScript API Page 21 of 36
developerWorks® ibm.com/developerWorks/
<war destfile="./ICMCustomWidgets.war"
webxml="./WebContent/WEB-INF/web.xml">
<fileset dir="./WebContent">
<include name="**/*.*" />
</fileset>
</war>
</target>
<target name="createEAR">
<ear destfile="./ICMCustomWidgets.ear"
appxml="./WebContent/META-INF/application.xml">
<fileset dir="." includes="*.war"/>
</ear>
</target>
11. In the New File window, type build.xml as the file name
<target name="package">
<ant antfile="${plugin.home}/build.xml" >
<property name="basedir" value="${plugin.home}"/>
</ant>
<ant antfile="${webapp.home}/build.xml">
<property name="basedir" value="${webapp.home}"/>
</ant>
<zip destfile="../ICMCustomWidgets.zip">
<fileset dir="${plugin.home}">
<include name="*.jar" />
</fileset>
<fileset dir="${webapp.home}">
<include name="*.ear" />
</fileset>
Creating custom widgets with the IBM Case Manager JavaScript API Page 22 of 36
developerWorks® ibm.com/developerWorks/
<zipfileset dir="../ICMRegistry"
prefix="ICMRegistry">
</zipfileset>
</zip>
</target>
1. In the Case Manager configuration tool, right-click the profile and then click Add
New Task > Deploy and Register Widgets Package to create a new task.
Creating custom widgets with the IBM Case Manager JavaScript API Page 23 of 36
developerWorks® ibm.com/developerWorks/
2. Add the custom widget package file to Widgets package file path, run the task.
Creating custom widgets with the IBM Case Manager JavaScript API Page 24 of 36
developerWorks® ibm.com/developerWorks/
Creating custom widgets with the IBM Case Manager JavaScript API Page 25 of 36
developerWorks® ibm.com/developerWorks/
Creating custom widgets with the IBM Case Manager JavaScript API Page 26 of 36
developerWorks® ibm.com/developerWorks/
1. On the Manage Solutions page, find your solution and click Deploy. The status
icon turns green as the solution is deployed to your development environment.
When the solution deploys successfully, the status icon remains green and dis-
plays a check mark.
Tip: If a solution fails to deploy, the status icon turns red and displays an X. You
can view errors by clicking More Actions > Errors.
2. After the solution deploys, click Test and log in to Case Manager Client.
The first time you test a solution, you are not a member of a role that has access to
the solution so you must assign yourself to a role.
Creating custom widgets with the IBM Case Manager JavaScript API Page 27 of 36
developerWorks® ibm.com/developerWorks/
Appendix
Extending an IBM Case Manager page widget
In addition to creating custom page widgets, you can customize the page widgets that are
provided by IBM Case Manager. This example extends the Case Information widget to
show this type of customization.
In this example, we make the following changes to the Case Information widget:
The following diagram shows the code structure of case information page widget.
1. Create a dijit to display case comment in a tab of the Case Information widget.
This dijit must inherit from the
icm/pgwidget/caseinfo/dijit/CaseInfoComponentContentPane, which is an
abstract template dijit that defines the contracts between the Case Information
widget and the dijit that is embedded in its tab.
Creating custom widgets with the IBM Case Manager JavaScript API Page 28 of 36
developerWorks® ibm.com/developerWorks/
publishing events. This means that the custom tab dijit need only implement the
render() method to render the tab user interface.
2. Create a custom case information page widget extends from the ICM case
information page widget icm/pgwidget/caseinfo/CaseInfo, creating the comment
tab dijit and add it as a child of the Case Information widget.
3. Override the handler function for the icm.SendWorkItem event and then bind the
received WorkItemEditable model object to its action context. This enables the
user to add the custom action AddDocumentToAttachment to access the work
item information from the action context.
Creating custom widgets with the IBM Case Manager JavaScript API Page 29 of 36
developerWorks® ibm.com/developerWorks/
After you add the case comment to the Case Information widget, the widget becomes
writable rather than read only. When the user adds the widget to a Case Detail page or a
Work Details page, the widget will work like other page widgets in the page to:
Mark page dirty state if there are unsaved comments, and clear the dirty state
when save complete.
Save comments when user click the save button on the toolbar.
Notify to user if there is unsaved comments when user click close button on
toolbar.
Creating custom widgets with the IBM Case Manager JavaScript API Page 30 of 36
developerWorks® ibm.com/developerWorks/
When the user adds the custom Case Information widget to a Work Details page, the add
case document as attachment action supports:
Rendering the attachment list of a work item as submenu when a case worker
select a case document and bring up the context menu.
Creating custom widgets with the IBM Case Manager JavaScript API Page 31 of 36
developerWorks® ibm.com/developerWorks/
The getIterator() function gets the WorkItemEditable model object from action context
that was injected by the parent custom Case Information page widget in the preceding
step. The function then returns the list of attachments for the WorkItemEditable model
object. The action framework renders the attachment names as a list in the submenu.
When a case worker specifies an attachment name, the framework calls the execute()
function and the action publishes an icm.AddDocumentAsAttachment event with a case
document and an attachment name in the payload.
Creating custom widgets with the IBM Case Manager JavaScript API Page 32 of 36
developerWorks® ibm.com/developerWorks/
Creating custom widgets with the IBM Case Manager JavaScript API Page 33 of 36
developerWorks® ibm.com/developerWorks/
5. Browse to the folder that contains the custom widget project, select the
customWidget project, and click Finish.
Creating custom widgets with the IBM Case Manager JavaScript API Page 34 of 36
developerWorks® ibm.com/developerWorks/
6. Run build
Creating custom widgets with the IBM Case Manager JavaScript API Page 35 of 36
developerWorks® ibm.com/developerWorks/
Creating custom widgets with the IBM Case Manager JavaScript API Page 36 of 36