Posted by: jacobdotcosta | 05/11/2010

Virtual Beans

MBO code snippet
Image by jacobdotcosta via Flickr

By default dialog boxes in Maximo are created with connection to the main application. This is very helpful because you can access record data in the application without having to write any code. Using the default methods you can obtain the MboSet in the list tab and it’s records or the record loaded in an application. The drawback with this approach is that to use the dialog box at least one record must be loaded in the application. Whenever you try accesing a dialog without having records loaded in the application you’ll be presented with an emty and readonly dialog.

This post shows how to create a dialog box that doesn’t have any support on the loaded application.

The idea behind this implementation is that the dialog doesn’t depend on the Mbo loaded on the application. For that we will use a non persistent MboSet with non persistent attributes and a beanclass that extends from AppBean instead of the usual DataBean.

The MboSet

The first step required is to create a new MboSet, a non persistent one, that will store the information obtained from the dialog box. The attributes will be the ones necessary on the dialog.

The MboSet class

Instead of extending the usual psdi.mbo.MboSet class this MboSet must extend from psdi.mbo.NonPersistentMboSet class as it is a non persistent Mbo. The Mbo classes don’t need to have any other type of customization.

The Dialog

Once the MboSet and it’s attributes are created and the database is configured it’s time to move on to the dialog itself. First of all we’ll modify the xml of the application to include our new dialog box. This dialog box must use the non persistent mbo just created and not make any reference neither to the Mbo on the main application nor to it’s datasources. None of the attributes in the dialog should reference MAINRECORD as their data source. Here’s an example of what this dialog would look like.

<code><span style="font-family: Verdana,sans-serif;">
<pre><dialog id="mycustomdialog" mboname="MYNONPMBO" beanclass="net.openmaximo.webclient.beans.myappname.MyDialogAppBean" label="Dialog Label" >
  <section id="mycustomdialog_1" >
    <textbox id="mycustomdialog_1_1" dataattribute="FROMDATE" lookup="datelookup" />
    <textbox id="mycustomdialog_1_2" dataattribute="TODATE" lookup="datelookup" />

  <buttongroup id="mycustomdialog_2" >
    <pushbutton id="mycustomdialog_2_1" default="true" mxevent="dolongop" label="Accept" />
    <pushbutton id="mycustomdialog_2_2" mxevent="dialogcancel" label="Cancel" />


The dialog bean class

This dialog will execute an execute() method created on the MyDialogApBean class presenting a longop box.

Finally when creating the bean class have in mind it must extend from the AppBean class.

protected DataBean appBean;
public int execute() throws MXException, RemoteException {
  // The MBO on the dialog is loaded this way.
  MboRemote newMbo = this.getMbo();
  // Accessing it's attributes
  java.util.Date dtFromD = newMbo.getDate("FROMDATE");
  java.util.Date dtToD = newMbo.getDate("TODATE");
  // Finally to present some kind of message to the user when the process ends a message stored in MAXMESSAGES is used.
  SimpleDateFormat sdFormat = new SimpleDateFormat("dd/MM/yyyy");
  String sFromDate = sdFormat.format(dtFromD);
  String sToDate = sdFormat.format(dtToD);
  Object param[] = {
    sFromDate,  sToDate
  ((MboSet)app.getResultsBean().getMboSet()).addWarning(new MXApplicationException("msgroup", “msgkey”, param));
  return 1;

This dialog would lunch a process presenting the long operation box and would present a message when finished.

Changes to this post

2010/11/22 Just made a correction to the dialog's XML source. The textbox included a reference to the MAINRECORD datasource that was incorrect.


Enhanced by Zemanta


  1. […] This post was mentioned on Twitter by Chon Neth, said: Virtual Beans « openmaximo #maximo #customization […]

  2. thanks for the tutorial.

    i have a question.
    is that posible for me to take a current data from the parent application?


  3. Code Snippets are good, full implementation instructions and source code is better. 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: