Creating a new custom presentation bean

You can create a new bean to control your custom dialog.

You create a new bean when you want to:

  • Pre-populate attribute fields with data from other sources
  • Extend current button functionality
  • Add new button functionality

The new bean must extend PmScInputSpecBean, which is the default bean for all dialogs.

New Bean Class:
package com.ibm.ism.pmsc.webclient.beans.shoppingcr;

import java.rmi.RemoteException;

import psdi.mbo.MboConstants;
import psdi.util.MXException;

public class MyCustomPresentationBean extends PmScInputSpecBean {
/* Insert new or overridden routines here */
	
}

In your custom dialog, the beanclass property is changed from PmScInputSpecBean to MyCustomPresentationBean.

Pre-populating attribute fields

By default, attribute input fields are pre-populated with the default value of the Attribute specified in the offering definition. If no default value is defined for the attribute, the input field will be blank.

By overriding the initialize routine in MyCustomPresentationBean, you can pre-populate these attribute input fields from other sources. The following is a simple example of initializing two fields using the setValue method. However, the code in the setValue routine must be replaced with much more complicated code to pull data from other processes or databases in your environment. For example, the code can access your company's LDAP service and pull user information to initialize the fields.
protected void initialize() throws MXException, RemoteException
{
	super.initialize();
	this.setValue("aln1", "John Doe", MboConstants.NOACCESSCHECK);
	this.setValue("num2", "12345", MboConstants.NOACCESSCHECK);
	moveTo(0);
}

Overriding button functionality

By default, there are five buttons supported on offering dialogs. The button functionality is supported by methods in PmScInputSpecBean as follows:
Table 1.
Button PmScInputSpecBean Functionality Notes
Add to Cart opencrdr() Copies attribute input information from PMSCCRSPECV records to TICKETSPEC records and launches Shopping Cart application. Only valid for supply chain services in Offering Catalog object
Execute/Launch execute() Copies attribute input information from PMSCCRSPECV records to TICKETSPEC records and launches workflow or launch-in-context entry associated with action service. Only valid for action services in Offering Catalog object
Cancel cancelClicked() Cleans up records created when offering was selected and closes dialog. none
Add to Favorites addtofav() Adds the selected offering to the Favorite Offerings list. Only appears if offering not already in Favorite Offerings
OK okClicked() Updates TICKETSPEC records with the values entered by the user. Only valid for Shopping Cart, View Shopping Carts, and View Catalog Requests objects

You can override any one of the PmScInputSpecBean routines to extend the functionality provided.

The following is a simple example of overriding the execute() routine to log an “Executing service” message before initializing the workflow or launch in context:
int execute() throws MXException, RemoteException
{
      System.out.println("Executing service");
      super.execute();
      return EVENT_HANDLED;
}

In a more complicated scenario, if you have an external application that reads data from table A in database XYZ, you could override the bean's execute routine to copy any information from the Service Catalog database records (e.g. PMSCCRSPECV, PMSCCR, PMSCOFFERING) to table. Once you complete the tasks then call the super.execute() routine to launch the external program.

The method signatures you can currently override are:
int execute() throws MXException, RemoteException
void addtofav() throws MXException, RemoteException
int opencrdr() throws MXException,  RemoteException 
int cancelClicked() throws MXException,  RemoteException
int okClicked() throws MXException,  RemoteException

Adding new button functionality

New buttons can be added to a dialog and new methods created in your customized bean (e.g. MyCustomPresentationBean). As an example, a new button could be created in the custom presentation called “Email to me” with an “email” event handled by new method email() added to MyCustomPresentationBean.
int email() throws MXException, RemoteException
{
    /* Add code to gather information from PMSCSRVOFF record to send to user */
    /* Add code to email information to user*/
    return EVENT_HANDLED;
}