Add external Java class
The entity action allows you to use Java code to extend the functionality of your application in ONEWEB. This section will show you how to add custom Java code to your entity.
Configuring Class Action
Go to AppDesigner and open your entity.
In the navigator pane, under Tool -> Action, Drag and drop to the entity.
Click to open Module Action Field Configuration.
Select Process Name: UPDATE
Enter Class Action: com.training.manual.ApplicationManualClass, click OK to save dialog.
Perform the steps 2 - 5. for the Process Name: INSERT
Click Save the configuration.
Create a Java Class file using Eclipse
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;
}
}
There are 2 default methods generated.
public Vector modifyResult(): to modify the submitted data model before process INSERT/UPDATE/DELETE to the database.
public boolean validateResult() : to validate submitted data model, return true if validate pass.
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();
}
}
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.
To test the ApplicationManualClass class, open http://<host>:8080/FrontWeb in web browser and login application.
Click Create Application menu to open Create Application screen.
Click Add button.
In Application Detail, enter data of application and click Submit button.
In the Eclipse, Open Console tab, the standard out should display like this:
Last updated