The entity action allows you to use Java code to extend the functionality of your application in ONEWEB. In this section will show you how to add custom Java code into your entity.

Configuring Class Action


  1. Go to AppDesigner and open your entity.
  2. In the navigator pane, under Tool -> Action, Drag and drop to the entity.



  1. Click to open Module Action Field Configuration.
  2. Select Process Name: UPDATE 
  3. Enter Class Action: com.training.manual.ApplicationManualClass, click OK to save dialog.



  1. Perform the steps 2 - 5. for the  Process Name: INSERT
  2. Click Save the configuration.

Create Java Class file using Eclipse


  1. From the Eclipse IDE, On the Project Explorer Pane, right click on /MasterWeb/Java Sources/src folder, select New > Class and name the class ApplicationManualClass. Click Finish to create the Java Class file.


The class generated should look like:


package com.training.manual;


import java.util.Vector;


import com.master.util.ProcessAction;

import com.master.util.ProcessHelper;


public class ApplicationManualClass extends ProcessHelper implements ProcessAction {


       @Override

       public Vector modifyResult() {

               // TODO Auto-generated method stub

               return null;

       }


       @Override

       public boolean validateResult() {

               // TODO Auto-generated method stub

               return false;

       }

}


  1. There are 2 default methods generated.
    • public Vector modifyResult() : to modify submitted data model before process INSERT/UPDATE/DELETE to database.
    • public boolean validateResult() : to validate submitted data model, return true if validate pass.


  1. Modify ApplicationManualClass to print out submitted data and the name of clicked button.


package com.training.manual;


import java.util.HashMap;

import java.util.Vector;


import com.master.util.ProcessAction;

import com.master.util.ProcessHelper;


public class ApplicationManualClass extends ProcessHelper implements ProcessAction {


       @Override

       public Vector modifyResult() {


               Vector vDataModels = getResultForProcess();

               String buttonAction = request.getParameter("SUBMIT_BUTTON");

               

               System.out.println("######## data: " + vDataModels);

               System.out.println("######## buttonAction: " + buttonAction);

               

               return vDataModels;

       }


       @Override

       public boolean validateResult() {

               return true;

       }


       @Override

       public HashMap modifyLoadUpdateResult() {

               return super.modifyLoadUpdateResult();

       }

}


  1. In the Servers view, Right-click the server and select Publish from the menu. The state changes to Synchronized once the project has been deployed to the server.
  2. To test the ApplicationManualClass class, open http://<host>:8080/FrontWeb in web browser and login application.
    1. Click Create Application menu to open Create Application screen.
    2. Click Add button.
    3. In Application Detail, enter data of application and click Submit button.
    4. In the Eclipse, Open Console tab, the standard out should display like this: