Retrieving A Value from a Form

Once you have set up and initialized your application with the API and loaded a form into memory, your application is ready to start working with the form. The following code uses getLiteralByRefEx to get a specific value from the form:

  1. Define the method getBirthDay and a string variable called temp.
       private static int getBirthDay( ) throws Exception
          {
          String temp;
    
  2. Call getLiteralByRefEx to retrieve the literal information contained in the form node PAGE1.BIRTHDAY.value
             temp = theForm.getLiteralByRefEx(null, "PAGE1.BIRTHDAY.value", 0, 
                null, null);
    
    • If the method returns a literal value, convert it into an integer value; otherwise, indicate that no value was entered into the field and throw an exception.
            if (temp.length( ) > 0)
            {
               return Integer.parseInt(temp);
            }
            else
            {
               throw new UWIException("The birth day was not entered.");
            }
         }
      
  3. Define the following methods to retrieve the user's birth month and year from the input form. These methods will be exactly the same as getBirthDay except for the parameters passed to getLiteralByRefEx.
    • getBirthMonth( ) — retrieves the value PAGE1.BIRTHMONTH.value from theForm.
    • getBirthYear( ) — retrieves the value PAGE1.BIRTHYEAR.value from theForm.