This entry is part of the Maximo Java Development series.
In this post I will describe all the steps needed to execute custom Java code upon the selection of an entry in the action menu or the click of a button in the toolbar.
Add a sigoption
First you need to create a new sigoption. Open the Application Designer and select the application you want to modify. Select ‘Add/Modify Signature Options’ and create a new signature RUNJAVA.
Add the menu entry
The second step is to create the custom entry in the action menu (or a new button).
Select ‘Add/Modify Select Action Menu’ and create the new entry RUNJAVA of type OPTION. Beware that the name must be the same as the sigoption.
Grant sigoption permissions and test the dummy action
Before going on I recommend the test that the new menu entry is visible.
Go in the Security Groups application, select the group you want to be able to see and execute the custom code. Go in the Applications tab and select your application. Now you should see the RUNJAVA sigoption on the bottom of the page. Click on the checkbox to grant access to the new menu entry.
Disconnect and login with a user belonging to the chosen group, go in the application and verify that you see the new menu entry.
Now it’s time to attach your Java code to it.
Write your Java code
The most suitable place to put your Java code is in the ‘App Bean Class’ which is the custom Java class that manages the application.
To determine which Java bean handles the application, open Application Designer and select the application, from the Action menu choose ‘Toggle Show All Controls’ and display the properties of the ‘presentation’ section. The ‘App Bean Class’ defines the Java class that you need to customize. Here is the WOTRACK application App Bean Class definition.
You should extend this class and create a new method with the same name of the sig option in the Java bean class (RUNJAVA in our example).
Don’t forget to change the App Bean Class property setting your own custom class.
Here is an example of how the custom class should look like.
public class CustWorkorderAppBean extends psdi.webclient.beans.workorder.WorkorderAppBean
public int RUNJAVA() throws MXException, RemoteException
// put your custom code here
Implement your custom logic in the RUNJAVA method and copy the class file under [SMPDIR]\maximo\applications\maximo\maximouiweb\webmodule\WEB-INF\classes folder. Rebuild and redeploy Maximo EAR file.