Community articleduplicate 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 makes a copy of a node. The duplicated node can be attached to any other node as either a sibling or a child, or can be stored as a separate node structure. The new node can also be assigned a new identifier with the theIdentifier parameter. All of the properties of the original node are duplicated, including any children and any namespace settings.
Note: If you duplicate a node that is not in the XFDL namespace, the namespace is copied as part of the duplicated node, but is not set globally.

Method

   public FormNodeP duplicate(
      FormNodeP baseNode,
      int where,
      String theIdentifier
   ) throws UWIException;


Parameters

Table 1. Method parameters
ExpressionTypeDescription
baseNodeFormNodePThe formNodeP to attach the new copy to. If null, then the node on which it is called is used as the baseNode.
where intA constant that describes the location in relation to the supplied baseNode in which the new node should be placed. Can be one of:
XFDL.UFL_APPEND_CHILD — adds the new node as the last child of the baseNode.
XFDL.UFL_AFTER_SIBLING — adds the new node as a sibling of the baseNode, placing it immediately after that node in the form structure.
XFDL.UFL_BEFORE_SIBLING — adds the new node as a sibling of the baseNode, placing it immediately before that node in the form structure.
XFDL.UFL_ORPHAN — copies the node but does not insert it into the form structure.
theIdentifierStringThe new id attribute for this node. If null, the id attribute of the original node is used.


Returns

The duplicate node or throws a generic exception (UWIException) if an error occurs.

Example

In the following example, dereferenceEx is used to locate a specific node. duplicate is then used to duplicate that node.
   private static void createMailing( )throws UWIException
   {
   FormNodeP tempNode;
   FormNodeP duplicateNode;
 
      if ((tempNode = theForm.dereferenceEx(null, "PAGE1.ADDRESSFIELD", 
         0, FormNodeP.UFL_ITEM_REFERENCE, null)) == null) 
      {
         throw new UWIException("Could not locate ADDRESSFIELD node."); 
      }
 
      if ((duplicateNode = tempNode.duplicate(tempNode,
         XFDL.UFL_AFTER_SIBLING, "MAILINGFIELD")) == null)
      {
         throw new UWIException("Could not duplicate ADDRESSFIELD node.");
      }
 
   }


Parent topic:
FormNodeP class