Using the Worklist
WebLogic Integration Worklist user interfaces (UI) enable end users to interact with running business processes. Generally, people interact with Tasks in WebLogic Integration through custom-user interfaces. A typical example is a mortgage loan processing interface for loan origination, underwriting, closing, funding, and delivery.
With the Enterprise JavaBeans (EJB) API, you can use the Worklist EJB to create and manage tasks independent of the business process (JPD) created in WebLogic Workshop.
This section includes the following information:
WebLogic Integration contains a sample Worklist user interface. This sample interface provides basic out-of-the-box functionality for inspecting and updating tasks. The worklist user interface is built as a WLI project that you can open in WebLogic Workshop. The source code is located in the following directory:
BEA_HOME
\weblogic81\integration\lib\worklistApp
In the previous line, BEA_HOME
represents the directory in which you install the WebLogic Platform.
You can create a custom Worklist user interface using the Worklist controls and the Worklist API. The Worklist controls and API provide the following operations needed to design custom user interface pages:
Additionally, you can use NETUI to leverage the Worklist controls in your custom-user interfaces and use the Worklist API with JavaServer Pages (JSPs).
To learn more about the Worklist API, see the com.bea.wli.worklist.api
package in the BEA WebLogic Integration Javadoc.
WebLogic Workshop controls can be invoked from a Web page. You can create a custom Worklist user interface or portal using the WebLogic Workshop tools to manage Web applications using JSPs and Page Flows. For more information, see Developing Web Applications and Page Flows and JSPs in the WebLogic Workshop Help.
To access the sample Worklist user interface in your installation of WebLogic Platform, take the following steps:
weblogic
and weblogic
, respectively.A JSP page is displayed. It allows you to view and manage the tasks in your application.
Note: Only the latest 250 tasks are shown on each page. They are displayed in descending order from creation time. If you have more than 250 tasks, the undisplayed tasks will be moved into the list as the displayed tasks are completed and removed from the list.
The worklist public API is in the package com.bea.wli.worklist.api
. To learn more about the Worklist API, see this package in the BEA WebLogic Integration Javadoc.
The following sample code shows you how to access the Worklist interfaces from a client application.
protected Context getInitialContext(String url, String user, String
password)
throws Exception
{
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, url);
h.put(Context.SECURITY_PRINCIPAL, user);
h.put(Context.SECURITY_CREDENTIALS, password);
h.put(Context.SECURITY_AUTHENTICATION, "simple");
return new InitialContext(h);
}
Alternative 1—using the WorklistManager
public WorklistManager getWorkListManager() throws Exception {
RemoteWorklistManagerHome home;
Object ref;
Context ctx = getInitialContext("t3://localhost:7001",
"installadministrator", "installadministrator");
try {
// Obtain a reference to the RemoteWorklistItemManagerHome
ref = ctx.lookup("RemoteWorklistManagerBean");
// Cast object returned by the JNDI lookup to the appropriate datatype
home = (RemoteWorklistManagerHome) PortableRemoteObject.narrow(ref,
RemoteWorklistManagerHome.class);
// Use the home interface to create a new instance of the bean.
return(WorklistManager) PortableRemoteObject.narrow( home.create(),
RemoteWorklistManager.class);
} finally {
ctx.close();
}
}
Alternative 2—using the WorklistScrollableResultManager
public WorklistScrollableResultManager getWorklistScrollableResultManager()
throws Exception {
RemoteWorklistManagerHome home;
Object ref;
Context ctx = getInitialContext("t3://localhost:7001",
"installadministrator", "installadministrator");
try {
// Obtain a reference to the RemoteWorklistManagerHome
ref = ctx.lookup("RemoteWorklistManagerBean");
// Cast object returned by the JNDI lookup to the appropriate datatype
home = (RemoteWorklistManagerHome) PortableRemoteObject.narrow(
ref, RemoteWorklistManagerHome.class);
// Use the home interface to create a new instance of the bean.
return (WorklistScrollableResultManager) PortableRemoteObject.narrow(
home.create(), RemoteWorklistManager.class);
} finally {
ctx.close();
}
}
public WorkSubstituteManager getWorkSubstituteManager() throws Exception {
RemoteWorklistManagerHome home;
Object ref;
Context ctx = getInitialContext("t3://localhost:7001",
"installadministrator", "installadministrator");
try {
// Obtain a reference to the RemoteWorklistItemManagerHome
ref = ctx.lookup("RemoteWorklistManagerBean");
// Cast object returned by the JNDI lookup to the appropriate datatype
home = (RemoteWorklistManagerHome) PortableRemoteObject.narrow(ref,
RemoteWorklistManagerHome.class);
// Use the home interface to create a new instance of the bean.
return(WorkSubstituteManager) PortableRemoteObject.narrow( home.create(),
RemoteWorklistManager.class);}
} finally {
ctx.close();
}
}
Caution: You may be tempted to use the remote WorklistManager
instance directly. This is generally not a good idea because the RemoteWorklistManager Interface
extends both the WorkSubstituteManager
and WorklistManager
interfaces. This interface contains specific methods that are not intended to be public and therefore are not supported by BEA. If used incorrectly, these methods may hamper the Worklist system.
Now that you know how to access the Worklist EJB API, here are some short examples:
This following method returns all the task IDs of the tasks whose name starts with an "a".
public String[] getIds() throws Exception {
try {
WorklistManager wm = getWorklistManager();
TaskSelector selector = new TaskSelector();
selector.setTaskName("a%", true);
return wm.getTaskIds(selector);
} catch (Exception ex) {}
}
Note: To learn more about selection patterns, see the TaskSelector in the BEA WebLogic Integration Javadoc.
Note: To specify a range of results that are returned from a query, use the WorklistScrollableResultManager Interface
. For more information, see WorklistScrollableResultManager Interface.
The following example shows you how to create a task, set a request message XML, assign it to the user Joe, and return the taskId
.
public String createTestTask() throws Exception {
try {
WorklistManager wm = getWorklistManager();
String id = wm.createTask("test");
XmlObject request = XmlObject.Factory.parse("<TaskRequest/>");
wm.setTaskRequestAsXmlObject(request, "xml/test", id);
wm.assignToUser("joe", id);
return id;
} catch (Exception ex) {}
}