Community articlecreate 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 creates a new FormNodeP and attaches it to the form hierarchy at the indicated location. Once created, the type and identifier of a FormNodeP cannot be changed.
Note that you can also use setLiteralByRefEx to create a FormNodeP at the option level and below. Using setLiteralByRefEx is often easier and faster than using create.

Method

   public FormNodeP create(
      FormNodeP aNode,
      int where,
      String theType,
      String theLiteral,
      String theFormula,
      String theIdentifier
      ) throws UWIException;


Parameters

Table 1. create parameters
ExpressionTypeDescription
aNodeFormNodePThe new FormNodeP is placed in the form hierarchy in relation to this node. If null, this creates a new FormNodeP hierarchy (a new form)
whereint
A constant that describes the location, in relation to the parameter aNode, in which the new node should be placed:
XFDL.UFL_APPEND_CHILD — adds the new node as the last child of aNode.
XFDL.UFL_AFTER_SIBLING — adds the new node as a sibling of aNode, placing it immediately after that node.
XFDL.UFL_BEFORE_SIBLING — adds the new node as a sibling of aNode, placing it immediately before that node.
Note: If the parameter aNode is null, then this parameter should be set to 0.
theTypeStringThe type to assign to the FormNodeP being created. This is only necessary for page and item nodes. Use null for all other nodes. The type cannot be changed after the node has been created.
If you are creating a non-XFDL node, you must also include the namespace that the node should belong to, as shown:
   <namespace prefix>:<type>

For example:
   custom:myItem

If you do not provide a namespace, the method will assign the default namespace for the form.
theLiteralStringThe literal to assign to this FormNodeP. null is valid.
theFormulaStringThe formula to assign to this FormNodeP. null is valid.
theIdentifierStringThe identifier to assign to this FormNodeP. The identifier cannot be changed after the node has been created. null is valid.
If you are creating an option or argument level node, this must also include the namespace the node should belong to. Use the following format:
   <namespace prefix>:<type>

For example:
   custom:myOption

If you do not provide a namespace, the method will assign the default namespace for the form.


Returns

The new FormNodeP or throws a generic exception (UWIException) if an error occurs.

Example

In the following example, dereferenceEx is used to locate a specific node. create is then used to create a sibling to that node and to place it directly after that node in the form structure.
   private static void addPicLabel(FormNodeP theForm) throws Exception
   {
   FormNodeP tempNode; 
   XFDL theXFDL;
 
      if ((theXFDL = (XFDL)IFXMan.lookupInterface(XFDL.XFDL_INTERFACE_NAME,
         XFDL.XFDL_CURRENT_VERSION, 0, null, null)) == null)
         throw new UWIException("Could not find interface");
 
   /* Call theForm.dereference to locate the node for the gender label item. */
 
      if ((tempNode = theForm.dereferenceEx(null, "PAGE1.GENDERLABEL", 0,
         FormNodeP.UFL_ITEM_REFERENCE, null)) == null)
      { 
         throw new UWIException("Could not locate GENDERLABEL node.");
      } 
      tempNode = theXFDL.create(tempNode, XFDL.UFL_AFTER_SIBLING, 
         "label", null, null,"PICLABEL") 
   }


Parent topic:
XFDL class