Community articleRetrieving A Value from a Form
Added by IBM contributorIBM on May 3, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.

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.
  2.    private static int getBirthDay( ) throws Exception
          String temp;

  3. Call getLiteralByRefEx to retrieve the literal information contained in the form node PAGE1.BIRTHDAY.value
  4.          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);
               throw new UWIException("The birth day was not entered.");

  5. 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.