Callout
Contents
How to create a callout
What is a callout?
A callout is java method which is executed when field in an ADempiere window is modified. A callout class (extend CalloutEngine) groups different methods that are called when the column is changed using the UI. For a column you may specify a list of fully qualified methods (separated by ";").
Steps to create a callout
To write a callout you have to do the following things:
1. Write the callout function
package org.adempiere.callout; import java.util.Properties; import org.compiere.model.CalloutEngine; import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.util.AdempiereSystemError; import org.compiere.util.Env; public class SimpleCallout extends CalloutEngine { public String test(Properties ctx, int windowNo, GridTab mTab, GridField mField, Object value) throws AdempiereSystemError { log.fine("test callout"); log.fine("tab name: " + mTab.getName()); log.fine("window no: " + windowNo); log.fine("window name: " + Env.getWindow(windowNo).getName()); return "this is a return string"; } }
The full qualified name of the method is org.adempiere.callout.SimpleCallout.test - you will need this in the next step.
2. Login as system administrator and open the 'Table&Column' window. Navigate to the table and column to which you want to add your callout by typing the full qualified method name into the 'Callout' field. (You can add more than one callout if you seperate them with ';')
3. Create a jar file with your callout classes and rename it to customization.jar. Copy this customization.jar into the Adempiere/lib folder of your ADempiere installation and rerun the RUN_setup.bat/sh. Restart the ADempiere server and install the new client (or restart the client with Java WebStart).
4. Test your callout by navigating to the field where you added the callout and change it's value. If you used the test callout you should see it's output in the console (if your trace level is set to fine or a higher level). You can change the trace level in Tools -> Preference -> Trace Level.
Tips
You can have callout functions with 5 parameters (like in the example above) or 6 parameters. The last parameter is the old value.
public String callout (Properties ctx, String method, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue);
See also
- Script_Callout
- The old famous Callout.pdf.