Community articlesetFormula method
Added by IBM contributorIBM on August 15, 2011
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.



Description

This method sets the formula for a node.

Method

   public void setFormula(
      String theFormula
   ) throws UWIException;


Parameters

Table 1. Method parameters
ExpressionTypeDescription
theFormulaStringThe formula to assign to the node. If null, the formula is assigned as null.


Returns

Nothing if call is successful or throws a generic exception (UWIException) if an error occurs.

Example

In this example, dereferenceEx is used to locate an age field. setFormula is then used to set the appropriate formula for the field.
   private static void setFormula(int curMonth, int curDay, int birMonth, 
      int birDay) throws Exception
   {
   FormNodeP tempNode;
 
      theForm.dereferenceEx(null, "PAGE1.AGEFIELD.value", 0, 
         FormNodeP.UFL_OPTION_REFERENCE | FormNodeP.UFL_SEARCH_AND_CREATE, 
         null)
 
   /* The following logic simply identifies how the computation should be
      set.  If the current date is later in the year than the birth date,
      then the age is: current year - birth year.  If the current date is
      earlier in the year than the birth date, then the age is: current year
      - birth year - 1. */
 
      if ((curMonth > birMonth) || 
         (curMonth == birMonth) && (curDay > birDay)))
      {
         tempNode.setFormula("PAGE1.CURRENTYEAR.value -   
            PAGE1.BIRTHYEAR.value");
      }
      else
      {
         tempNode.setFormula("PAGE1.CURRENTYEAR.value -   
            PAGE1.BIRTHYEAR.value - \"1\"");
      }
 
      /* additional code removed */
   }


Parent topic:
FormNodeP class