Useful Tools and Components: Using Variable Packages (VarPacks)

Step 1: Implementing the VarPack

To create a custom VarPack, create a class that extends XMLBaseVarPack or BaseVarPack. XMLBaseVarPack handles the reading of xml files for you. For more detailed information, see the portal API Documentation. (The XMLBaseVarPack class was based on the latest VarPacks. Current VarPacks use the BaseVarPack class.)

To create a custom VarPack, follow the steps below. For a simplified example, see the Hello World VarPack sample code that follows.

  1. Create a custom project and custom VarPack class (e.g., a CustomVarPack project and a CustomVarPack class in com.yourcompany.application.varpacks that extends XMLBaseVarPack). For instructions on creating a custom project, see ALI Development Environment: Creating a Custom Project (Java | .NET).

  2. Edit the new class in your custom project as needed.

  3. Compile the new class into a new JAR/DLL file with an intuitive name. All VarPack file names should follow the standard naming convention and end with "VarPack" (e.g., CustomLoginVarPack).

Note: XMLBaseVarPack only reads in xml files that are two levels deep with the data in the value attribute of the lowest tag (<root><section><sub-section value=”data”>). It can be customized to read other formats, as explained below.

Example: Hello World VarPack

In this example, the HelloWorldVarPack class extends XMLBaseVarPack and reads in the contents of the helloworld.xml file and stores them on the application. As noted above, the name of the file is important; it ends with "VarPack".

Note: These instructions apply to AquaLogic Interaction (formerly called the Plumtree Portal) version 6.0. For details on the differences between versions, see the portal API documentation.

This example uses the sample code from the Developer Center: SampleProjects-60.zip. For details, see Installing UI Customization Sample Projects (Java | .NET).

  1. Install the files in the SampleProjects-50x.zip package and add the samplevarpack project to your IDE. (You must also set up your IDE for portal development as explained in Setting Up the Development Portal.)

  2. Open the HelloWorldVarPack file (.java or .cs) in the samplevarpack project in the src/com/plumtree/sampleui/application/varpacks directory (which is under the prod directory in Java). This file extends XMLBaseVarPack class (com.plumtree.uiinfrastructure.application.varpacks).

  3. The GetVarPackID() method provides the name that will be used to store this VarPack on the Application. The method returns a public static variable containing the name of the VarPack. The VARPACK_ID variable is is used to get the name of the VarPack so it can be retrieved from the Application.

    Java:

    /** The string ID of this variable package. */

    public static final String VARPACK_ID = "HelloWorldVarPack";

    public String GetVarPackID()

    {

       return VARPACK_ID;

    }

    C#:

    /// <summary>

    /// The string ID of this variable package.

    /// </summary>

    public const String VARPACK_ID = "HelloWorldVarPack";

    public override String GetVarPackID()

    {

       return VARPACK_ID;

    }

  4. The GetVarPackXMLFileName() method provides the name of the xml file to be read and stored in this VarPack.

    Java:

    public String GetVarPackXMLFileName()

    {

       // The name of the file to read into the VarPack.

       return "helloworld.xml";

    }

    C#:

    public override String GetVarPackXMLFileName()

    {

       // The name of the file to read into the VarPack.

       return "helloworld.xml";

    }

  5. As noted above, XMLBaseVarPack only supports the specific xml format <root><section><sub-section value=”data”>. To use xml files formatted in other ways, override the LoadSettingsIntoXPHashtable() method.

Once you have written the code for your new VarPack, you must deploy it for use by the portal, described in the next step.

Next: Step 2: Deploying a Custom Project