Community articlereadForm method (Streaming API)
Added by IBM contributorIBM on July 26, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Description

This method reads a form into memory from a specified file, Java Reader, or input stream.

Method

READING A FILE:
   public FormNodeP readForm(
      String theFilePath,
      int flags
      ) throws UWIException;

READING A STREAM:
   public FormNodeP readForm(
      InputStream theStream,
      int flags
      ) throws UWIException;

READING A READER:
   public FormNodeP readForm(
      java.io.Reader theReader,
      int flags
      ) throws UWIException;


Parameters

ExpressionTypeDescription
theFilePathStringThe path to the source file on the local disk.
theStream InputStreamThis is the stream that will read the form data. Note that this data must be UTF-8.
theReader java.io.ReaderThis is the reader that will read the form data.
flagsintXFDL.UFL_SERVER_SPEED_FLAGS — Turns off the following features: computes, automatic formatting, duplicate sid detection, XForms processing, write relevant, the event model, and relative page and item tags (for example, itemprevious, itemnext, and so on). As a result, this setting significantly improves server processing times.
Note that this setting does not respect XForms relevance.


Returns

Returns a new FormNodeP that is the root node of the form, or throws a generic exception (UWIException) if an error occurs.

Notes

Duplicate Scope IDs
If a form contains duplicate scope IDs (for example, two items on the same page with the same SID), readForm will fail to read the form and will return an error. This enforces correct XFDL syntax, and eliminates certain security risks that exist when duplicate scope IDs appear in signed forms.

Example

The following example demonstrates the use of readForm to load a form into memory, and then returns to the root node of the form.
   private static FormNodeP loadForm() throws Exception
   {
    XFDL theXFDL;
    formNodeP theForm;
      if ((theXFDL = IFSSingleton.getXFDL()) == null)
         throw new Exception("Could not find interface");
      if ((theForm = theXFDL.readForm("formSample.xfd",
         XFDL.UFL_SERVER_SPEED_FLAGS)) == null)
         throw new Exception("Could not load form.");
      return(theForm);
   }


Parent topic:
XFDL class