Creating a FunctionCall class

The FunctionCall class contains definitions for your custom functions. It also registers the FunctionCall object and each of the custom functions that it supports with the Forms System so that the functions and packages that it contains will be recognized.

  1. Create a new Java™ source file called FciFunctionCall.java.
  2. Define the Java package. For example:
       com.yourcompany.samples;
    
  3. Import the following API packages:
       com.ibm.form.api.ifx.IFX
       com.ibm.form.api.xfdl.FormNodeP
       com.ibm.form.api.xfdl.FunctionCallManager
       com.ibm.form.api.xfdl.FunctionCallImplBase
       com.ibm.form.api.xfdl.FunctionCall
       com.ibm.form.api.error.UWIException
    
  4. Import any other required files. In this case the following files are needed to implement the convertDate function:
       java.util.Date
       java.util.Locale
       java.text.DateFormat
       java.text.SimpleDateFormat
       java.text.ParseException
    
  5. Create a FunctionCall class that extends the pre-defined superclass com.ibm.form.api.xfdl.FunctionCallImplBase and implements the pre-defined interface FunctionCall.
    • In the following example the name of the FunctionCall class is FciFunctionCall.
         public class FciFunctionCall extends FunctionCallImplBase 
            implements FunctionCall
            {
               /* Additional code removed */ 
            }
      
  6. Define a unique identification number for each custom function that you are going to create using the FCI.
    • In the following example,FciFunctionCall contains a function called convertDate that converts any date to the date format and language of a specific country. The convertDate function in FciFunctionCall has an ID number of 1:
         public class FciFunctionCall extends FunctionCallImplBase 
            implements FunctionCall
            {
               public static final int CONVERTDATE = 1;
               /* Additional code removed */ 
            }
      
  7. Define a FunctionCall class constructor that takes as its parameter the IFX Manager.
    • In the following example, the constructor for the FciFunctionCall class is FciFunctionCall.
         public class FciFunctionCall extends FunctionCallImplBase 
            implements FunctionCall
            {
               public static final int CONVERTDATE = 1;
               
               public FciFunctionCall(IFX IFXMan) throws UWIException
               {
                     /* Additional code removed */ 
               }
            }
      
    • The IFXMan object represents the IFX Manager. Through this object all other objects and services can be reached.
    • UWIException is a generic exception.