Saving applet data

About this task

Various actions in a Notes® document, form, or page, such as resizing or editing applet parameters, cause the applet to reinitialize to the state it was in when you opened the document, form, or page. When the applet reinitializes, it loses data you entered and its current state. There are two methods for saving applet data:

  • Externalization

    The applet stores specific information that it needs in order to return to the state it was in before it was reinitialized. To maximize efficiency, it is recommended that you use externalization.

  • Serialization

    The applet stores all information, for example, each variable and its current value, each class, and all header information.

Considerations

About this task

Although you can set up an applet for both externalization and serialization, Notes cannot support both. An error is not reported, but one applet cannot do both.

In the Java™ applet itself, you must write methods to support the Java Externalize interface. If the applet does not have these methods, you can still run the applet. However, the data cannot be saved, even if you set up the parameters.

If you save data, keep these points in mind:

  • If the applet is imported in a subform, the data from the subform has precedence over the data in the form. Therefore, modifying an applet in a subform modifies all of the forms that include that subform.
  • Data from an applet contained in a document takes precedence over the data stored in a form or subform.

If you imported the applet in a document and you are saving data, the data file will be copied if you export the applet. If you imported the applet in a form, the data file will not be copied if you export the applet from a document you created with the form.

Externalization

About this task

There are three parameters available to direct Notes to save and reuse externalized data:

  • ReadExternalData

    Directly after reinitialization, the applet uses this parameter to load data previously saved.

  • ExternalData

    Any time after reinitialization, the applet uses this parameter to load data previously saved.

  • WriteExternalData

    After a Notes save event, the applet uses this parameter to save current data. The data is saved as an external object with an attachment in the document that references it. The attachment is hidden and cannot be seen by the user.

Usually you do not need to use both ReadExternalData and ExternalData. Use either one depending on when you want the applet to load data.

Generally, the values you assign to the parameters are the same.

To set up externalization

Procedure

  1. Select the Java applet and choose Java Applet - Java Applet Parameters.
  2. Click "Applet Parameter" in the Programmer's pane.
  3. If you want the applet to load data as soon as it has completed initialization, click Add and do the following:
    • In the Parameter Name field, enter ReadExternalData and click OK.
    • In the Parameter value window, enter the value for ReadExternalData. Its value is the name of a file that is attached to the page, form, or document where the applet is stored. For example, enter:
        	mydata
  4. If you want the applet to load data at some other point after initialization, click Add and do the following:
    • In the Parameter Name field, enter ExternalData and click OK.
    • In the Parameter value window, enter the value for ExternalData. Its value is the name of a file that is attached to the page, form, or document where the applet is stored. For example, enter:
      		mydata

    Notes appends the value with the entire URL of the data file.

  5. If you want the applet to save data at the end of the session, click Add and do the following:
    • In the Parameter Name field, enter SaveExternalData and click OK.
    • In the Parameter value window, enter the value for SaveExternalData. Its value is the name of a file that is attached to the page, form, or document where the applet is stored. For example, enter:
      		mydata

    If the file attachment does not exist, Notes creates it and stores the data in it.

Example HTML code

Serialization

About this task

There are two parameters available to direct Notes to save and reuse serialized data:

  • Object
  • WriteObject

To set serialization

Procedure

  1. Select the Java applet and choose Java Applet - Java Applet Parameters.
  2. Click Applet Parameters in the Programmer's pane, and then click Add.
  3. To load the previously saved data, enter the following in the Parameter Name field and click OK:
    Object
  4. In the Parameter value window, enter the value for Object. Its value is the name of a file that contains the previously saved state information from the WriteObject parameter. This file is attached to the page, form, or document where the applet is stored. For example, enter:
    mydata
  5. To save the applet data, click Add, enter the following in the Parameter Name field, and click OK:
    WriteObject
  6. In the Parameter value window, enter the value for WriteObject. Its value is the name of the file that is attached to the page, form, or document where the applet is stored. For example, enter:
    mydata

Example of HTML code

About this task

Your parameters might look like this:

<PARAM NAME="object" VALUE="mydata">
<PARAM NAME="writeobject" VALUE="mydata">