A Division of Technology Associates International Corporation
Maximo Blog

How to create a dialog box

June 04, 2009 in Maximo, Maximo 6, Maximo 7, Maximo: Programming by Michael Chrisman 10 Comments

Maximo provides many ways to add functionality to an Application Screen, from sub-tables to tabs. Another way is to add a dialog box. In Maximo, a dialog box is a ‘popup’ screen that appears on top of the current screen. You can use these to allow users to add more data to the current record or even as a way to generate new records based on the current record.  In this entry, I will go over how to create one of these.

The first step is to add any fields you will need for the screen. For a Maximo screen, a input field must be defined on an underling MBO. That being said, if it is a value that you will only use for a calculation on the screen and do not want to store, then add the field as a non-persistent field.

Next, we need to add a new dialog box to the screen in question. Sadly, there is no way to do this from the front end. The only way to do this is you have to export the application, then edit the XML with your favorite text editor. Then you need to add a new

   1:    <dialog id="mydialog" label="My New Dialog BOx" mboname="ASSET" beanclass="mycom.webclient.beans.asset.MyDialogBean" >
   2:       <section id="mydialog_grid1" >
   3:          <textbox id="mydialog_new_textbox_1" dataattribute="assetnum" label="Asset Number" inputmode="REQUIRED" />
   4:      section>
   5:   
   6:      <buttongroup id="mydialog_2" >
   7:        <pushbutton id="mydialog_2_1" default="true" mxevent="doaction" label="Action" />
   8:        <pushbutton id="mydialog_2_2" mxevent="dialogcancel" label="Cancel" />
   9:      buttongroup>
  10:    dialog>

Make sure this is not nested in another dialog box. Also you need to make sure that all ID attributes have unique names within the entire XML document. It really doesn’t matter what the content of the dialog is at this point as you can edit it using the Application Designer.  Now re-import your new XML screen.

Before we edit the dialog box, we need to make it so we can actually access it. The first step is to create a Signature Option for your new Dialog. To do this, Select Action->Add/Modify Signature Options.

sigOptions

Add a new option. For the Option field, make sure you give it the same name as the ID attribute on your tag (case does not matter). The description is what will be displayed in the security screen (yes, adding this means that your dialog box will have its own security). Now click ok.

Next you will need someway for the user to access your dialog box. If you want them to use the Select Action menu, then add an entry to the Add/Modify Select Action Menu. If you want it to appear on the tool bar, then add an entry to the Add/Modify Tool Bar Menu. If you want to add a button to the main screen that users can click on to access your dialog box, then in the properties of the button, for the ‘EVENT’ attribute, enter the name of your Signature Option you created (which is the same as the ID attribute of your tag).

Ok, now we can edit our new Dialog box. In App Designer, click on the Edit Dialog button (editDialog) and you will see an entry for ‘mydialog’ (or whatever you put for the ID attribute on the

dialogList

Click on your dialog box from the list to edit it.

dialogScreen

Now use the Application Designer to modify the screen as you need to. Unless this is just an extra data entry screen, you will want the screen to do something special when the user clicks one of the buttons. To do this, you will need to do a little java programming. If you look at our XML for our dialog, you will notice that the tag has a beanclass attribute. This is going to be the name of your custom bean class. We cover this in more detail in a next. But for the button to execute your custom code, you need to look at the properties for the button.

buttonProperties

The Event property is going to be the name of the method in the java bean to execute. Since this is a java method, case does matter.

Now that we have created our dialog box, we need to program our custom functionality. To do this, fire up Eclipse. You will want to create a new project. Create it like you would for MBO customizations but with the following changes:

Output folder: %maximoInstall%/applications/maximo/maximouiweb/webmodule/WEB-INF/classes
Add the External Class Folder: %maximoInstall%/applications/maximo/maximouiweb/webmodule/WEB-INF/classes

Now create a new Java class.

NewJavaClass

Now you need add your method. In this case we will add one called doaction.

   1:  package mycom.webclient.beans.asset;
   2:   
   3:  import java.rmi.RemoteException;
   4:   
   5:  import psdi.webclient.system.controller.Utility;
   6:  import psdi.webclient.system.controller.WebClientEvent;
   7:  import psdi.webclient.system.beans.*;
   8:  import psdi.server.MXServer;
   9:  import psdi.util.logging.FixedLoggerNames;
  10:  import psdi.util.logging.MXLogger;
  11:  import psdi.util.logging.MXLoggerFactory;
  12:   
  13:  import psdi.util.MXApplicationException;
  14:  import psdi.util.MXException;
  15:   
  16:  public class MyDialogBean extends DataBean
  17:  {
  18:      MXLogger appLog = MXLoggerFactory.getLogger(FixedLoggerNames.LOGGERNAME_APP + ".ASSET");
  19:      
  20:      public int doaction() throws RemoteException, MXException, ParseException
  21:      {
  22:          appLog.info("MyDialogBean :: enter doaction ......") ;
  23:          // put your code here
  24:   
  25:          return 1;
  26:      }
  27:   
  28:  }

Once you compile it, you will need to rebuild and redeploy the ear.

The last thing to do is to grant yourself access to the signature option on the screen. Now you can test it.

 

Technorati Tags: ,,,

Comments

Michael Chrisman
Posted on June 04, 2009

All,

Sorry about the XML sample. The new blog seams to like to eat some of the tag characters. Actually, it looks like it just eats ‘</’ characters.

Mike

Chon
Posted on June 12, 2009

Good stuff! Do you have any tutorials on how to extend an MBO class from beginning to end?

Michael Chrisman
Posted on June 16, 2009

Chon,

Check out: http://www.taic-sams.net/blog/article/extending-mbos/. Plus get a copy of the eclipse install guides (seach on this site for it as I have links to it.

Mike

Pankaj
Posted on June 26, 2009

Mike,

This is very useful.

I am also trying by following your instructions.

I have some questions:

1) In “edit dialog”, I created two buttons “okay” and “cancel”. For okay button property, what values shall set for “event”. In your example, it is “doaction”.

2) How “doaction” will understand to execute the bean class?

Where that association happens?

Thanks

Pankaj
Posted on June 26, 2009

Hello,

Now I understand what value I need to put for “event” attribute. It is the method of the bean class. Right?

By the way, it now giving me error “Exception occured in control ‘lbl_dialog’ (controltype= dialog) for the event ‘dialoginit’” afte I click on button that executes the bean class.

Any clue?

Thanks

Michael Chrisman
Posted on June 26, 2009

Pankaj,

That is correct. The event is the the name of the method.

As for the error, look in the log for the error details.

Mike

Mark
Posted on July 01, 2010

Great article.

I have a question. I applied the sample code and place the Java Method name to the event property of the button. However, when clicking the Action button, the dialog box does not close when the event is doaction. But when I use the dialogok event, I loose the doaction.

Thanks

Mark
Posted on July 02, 2010

Great article.

Question, I also want to close the dialog box when the “Action” Button is clicked. But I already using the “doaction” event.

sameer
Posted on July 08, 2010

HI All,
    Actually am novice into developing maximo application.I went through the code mentioned for the custom bean but I failed to understand why the return type for the doaction() is int and what is the utility of signature option
      Please elaborate!.smile

Also,it would be very helpful if provided some more tutorials for the begginers.

the blog- “http://www.taic-sams.net/blog/article/extending-mbos/” isnt available.

Michael Chrisman
Posted on August 14, 2010

My blog got moved and the URLs changed. You now need to add “index.php” to the url.

http://www.taic.sams.net/index.php/blog/article/extending-mbos

Post a Comment

Remember my personal information.
Notify me of follow-up comments?

We don't know if you're a human. Confirm below: