Forces one or more pages to be loaded into memory.
Use attachPage to ensure that the entire form and all of its pages are loaded into memory and are accessible to API methods. Forms that use the XFDL pageloading option do not always have all pages of the form loaded into memory. Although some methods might appear to work properly on pages that are not loaded, the results are not accurate. For example, checkValidFormats
will not report errors from pages that are not loaded, and you cannot print pages that are not loaded.
It is safe to call attachPage
on pages that are already loaded. It is also safe to call attachPage
on forms that do not use the XFDL pageloading option.
public void attachPage(
) throws UWIException;
Table 1. Method parameters
|pageSID||String||The sid of the page to attach, or null to attach all pages. You can also use an empty string ("") to attach all pages.|
Nothing or throws a generic exception (UWIException) if an error occurs.
The following example loads in a form, calls attachPage
to ensure that the entire form and all of its pages are loaded into memory, then calls checkValidFormats
Parent topic: FormNodeP class
private static void validateForm(String filename) throws Exception
FormNodeP  invalidItems;
// get an XFDL object
if ((theXFDL = IFSSingleton.getXFDL()) == null)
throw new Exception("Could not find interface");
// read in a form that has <pageloading> enabled
if ((theForm = theXFDL.readForm(filename, 0)) == null)
throw new Exception("Could not load form.");
// attach all pages before calling checkValidFormats
// call checkValidFormats
invalidItems = theForm.checkValidFormats();
if (invalidItems == null || invalidItems.length == 0)
System.out.println("All items in the form have valid formats.");
for (int i=0; i<invalidItems.length; i++)
theReference = invalidItems [i].getReferenceEx(null, null, null, false);
System.out.println("The item "+theReference+" has an invalid format.");
// clean up before exit