A Division of Technology Associates International Corporation
Maximo Blog

Creating a Custom Dialog- Part 2

March 08, 2009 in Maximo, Maximo 6, Maximo: Programming by Michael Chrisman 14 Comments

Now that we have our dialog box, the next thing is to add some custom functionality to the dialog box. In this example, we will add a button that when the user clicks it, it will call our custom code.

First we are going to create our custom java class. We will extend the DataBean class. In this class, create a method with whatever name you like. Make sure it has no parameters. In the method, do whatever processing you need.

   1:  
   2: package myCompany.webclient.beans.asset;
   3:  
   4: import java.rmi.RemoteException;
   5: import java.text.ParseException;
   6:  
   7: import psdi.webclient.system.controller.Utility;
   8: import psdi.webclient.system.controller.WebClientEvent;
   9: import psdi.webclient.system.beans.*;
  10: import psdi.util.logging.FixedLoggerNames;
  11: import psdi.util.logging.MXLogger;
  12: import psdi.util.logging.MXLoggerFactory;
  13:  
  14: import psdi.util.MXException;
  15:  
  16:  
  17: public class myDialogBox extends DataBean
  18: {
  19:     MXLogger appLog = MXLoggerFactory.getLogger(FixedLoggerNames.LOGGERNAME_APP + ".myDialogBox");
  20:     
  21:     public int dosomething() throws RemoteException, MXException, ParseException
  22:     {
  23:         appLog.info("myDialogBoxBean :: enter dosomething ……") ;
  24:         
  25:         try 
  26:         {
  27:             // Since screen variables are attributes on the MBO, we can use the this.getString
  28:             // to access them (or getBoolean, etc)
  29:             String myVar = this.getString("MY_CUSTOM_VAR");
  30:             
  31:             // Do stuff here…
  32:         } 
  33:         catch (Exception e)
  34:         {
  35:             appLog.error("ERROR: " + e + "n" + e.getStackTrace());
  36:         }
  37:  
  38:         // the following line will close the dialog box.
  39:         Utility.sendEvent(new WebClientEvent("dialogclose", app.getCurrentPageId(), null, sessionContext));
  40:  
  41:         appLog.info("myDialogBoxBean :: exit dosomething ……") ;
  42:  
  43:         return EVENT_HANDLED;
  44:     }
  45:  
  46: }

Since we added fields to the MBO object, we can access fields that users through the MBO.

NOTE: Databean class files need to go into the /applicationsmaximo maximouiwebwebmoduleWEB-INFclasses directory folder (instead of businessobjectsclasses folder).

Now save, compile, and rebuild/deploy ear.

Now we set the base class for the dialog box. Open the properties page for the dialog box.

img1

In the "Bean Class" field, add the name of your class.

Now we need to edit the properties of the button.

img2

In the 'Event' field, type in the of the method you created. This is Java, so case does matter. Now save the screen, and go test it.

If you have to make a change to your code, you will need to rebuild/deploy the ear to test it.

Comments

Henry
Posted on March 09, 2009

Your series on customizing dialog boxes is certainly timely! I am working on a customization to the move/modify assets dialog which is contained in the library.xml (version 7.1.) I am adding three new attributes on the Users and Custodians ‘modify all’ tab.

Would I modify the bean class as above, or do I need to modify the mboname referenced in the XML (assetusercustdflt)?

Mike
Posted on March 09, 2009

Henry,
It depends on what you are trying to do. If you looking to add some special processing to the attributes, then the MBO Class would be the place to do that. If you wanted to add special processing to a field on the screen only, then you would need to create a custom field class. The DataBean class is for adding functionality to buttons and events on a screen.
MikeC

Henry
Posted on March 10, 2009

Thanks for the clarification, Mike.
What I am doing is adding three fields to the screen which will be updated whenever a user/custodian changes. These new fields will end up in the assetlocusercust table, but one of these may end up in the asset table. Would I use a custom field class to do that?

Mike
Posted on March 10, 2009

Henry,
Yes, you would add a custom user field class to the user/custodian field that would populate the your new fields. If you add the class to the field at the MBO, then it will work when a change is made from the screen or from other methods (like teh MEA, etc).
MikeC

Henry
Posted on March 31, 2009

Hi Mike,
This is still giving me an issue. I’ve done some experiments with changes to the bean as well as the AssetLocUserCust MBO.  In debugging, I can see that if I make a reference in the save method of my extension to the AssetLocUserCust MBO to the MBO referenced in the XML file like this:

AssetUserCusDfltSetRemote my_remote = (AssetUserCusDfltSetRemote) getMbo();

–  and then do something like this:

setValue(“MY_HAND_REC”, myRemote.getString(“HAND_REC”));
then I can see the value entered in the XML, but it isn’t saving into the table (AssetUserCusDflt, attribute HAND_REC).
I’ve tried the same thing with some dummy text instead of going after the value entered in the dialog, but without success.
If I were to re-do this using a field class, what method would I extend, since there does not appear to be a save() method? Would I use the same technique as above to get the value entered?
Thank you for your time and patience. I am still new at this, and information seems hard to find at times.

Henry
Posted on April 01, 2009

I tried this as a field class, but found that it didn’t fire.

Matt
Posted on June 09, 2009

Hi Guys,.... wonder if anyone can help,..

I have created a custom pop-up box in the Incident application.

This has a relationship to TKCHANGESTATUS

I have added the ‘memo’ field on to the popup box which is from the
TKCHANGESTATUS mbo,. This all works well and the status changes and any info i
put in memo appears in the view status history…. which is great,

What I am having issues with is,.

I also wanted to add on 1 incident field,.. (a custom date field). To get it on
to the pop-up box without getting any invalid binding errors I had to add a
section and link this to the INCIDENT mbo,... I was then able to add my field.
The issue is that If I type anything in to this incident field, it doesn’t
actually write it to the table,? or if this value is already populated, when I
open the popup box I would expect it to be populated?....

I have the ok button on the bottom of the pop-up box, which I would assume would
save the changes?

Jason
Posted on August 05, 2009

Hi Matt, I have come acros a similar situation and the only way I could get around it was modifying the maxattributes directly in the database.
In 7.1 I add a new MBO that is persistent ( I wanted to have the view in the database) and based it on a view.  When you create a new persistent view you have to specify the object you are extending in my case the PO table.  Adding the extra fields as attributes I retrive from the view the default is to set them as non persistent and user defined.  This means they do not get populated from the view.  After setting them in maxattributes to persistent and not user defined, they will be populated if they have a value in them, and although I am only using them as display, I would forsee that they then do get written to the database.  I am not sure if this is a bug or I am just not seeing the option in my system.
But setting the maxattribute fields to persistent not user defined worked for me.  Make sure you set them in maxattributecfg as well and make a change in the database configuration so that the meta data etc is built correctly.

Let me know if this works for you.

Cheers,
Jason

Greg Hannah
Posted on September 01, 2009

Hi

  I’ve extended the combobox’s showmenu.jsp to include a new event.  How can I extend the DataBean class to call that new event.  I decompiled DataBean and threw the new method in there and it worked, but that’s not good.  I’d rather extend vs. overwrite DataBean.

Christian
Posted on November 25, 2009

Hi, I just stumbled across this blog looking for some information. I know this is totally unrelated to the post above, but I figured there should be some people reading this that are knowledgeable about Maximo. I am looking for a list that contains contidional properties and their values that tells me what I can and cannot use in the conditional properties of a field, button, or any object in App Designer (as in inputmode - required, for instance).
IBM (whom we have a support contract with) told me they do not have such a list - be it internal or available to the public.
Is there anyone who knows, at least some, of these properties and their values?

Compliance Monitoring
Posted on January 30, 2010

I would forsee that they then do get written to the database.  I am not sure if this is a bug or I am just not seeing the option in my system.

Michael Chrisman
Posted on February 24, 2010

Christian,

The best I can do is point you do the IBM docs (but I am not sure you will find what you are looking for. I have put together some links to IBM documents: http://www.planetchrisman.com/maximo.html.

MikeC

Indy
Posted on April 08, 2010

Speaking of dialog boxes….
When adding a new file in Add New Attachements Dialog box, is there any way to get the ‘Select a Folder’ (DocTypes) to come back sorted?  IBM did not include an order by - and Oracle will not bring back the data sorted.

Any ideas>

Michael Chrisman
Posted on April 11, 2010

Indy,

Sorry, no idea.

MikeC

Post a Comment

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

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