Show TOC

Background documentationData Model Locate this document in the navigation structure

 

The wizard framework, on which the editor framework is based, provides a data model that makes it easier to handle and store the data that administrators enter into the editor.

The data model provides the following benefits:

  • Holds data across requests, so that the data is available to all the panes and to the data handler.

  • Data items within the data model can be associated with wizard framework UI controls, so that data entered into the control is automatically saved into the data model, and values stored in the data model are automatically loaded into the controls.

    Wizard framework controls are defined in the com.sapportals.admin.wizardframework.components package.

The data model is a set of key-value pairs that is available via the editor context, which is exposed as an IEditorContext parameter in key methods of the editor framework.

For example, when the data handler's loadData() event is called, the editor context is supplied and you can load default values into the data model. The following example saves the value credit in the details.paymentMethod property of the data model:

Syntax Syntax

  1. public void loadData(
        IEditorContext context,
        IPrincipal principal,
        PPLogger logger)
        throws EditorDataException {
    
        context.setProperty("details.paymentMethod", "credit");
    }
    
End of the code.
Data Model and UI Controls

To synchronize a wizard framework UI control with a specific value in the data model, call setValueTargetPath() on the control and pass the property name in the data model that holds the control's value.

For example, the following creates an input field called Last Name, whose value is associated with the editor context property details.lastName.

Syntax Syntax

  1. TextInputComponent firstName = new TextInputComponent("Last Name");
    firstName.setValueTargetPath("details.lastName");
    
End of the code.

If you change the value in the data model, the control's value automatically changes. The following changes the value of the data model property details.lastName, which causes the value to be displayed in the Last Name control.

Syntax Syntax

  1. context.setProperty("details.lastName", "Smith");
End of the code.

HTMLB controls cannot be linked directly to the data model. Store the values of a pane's HTMLB controls into the data model during the processInput() method, as described in Step 1: Creating Panes.

Loading and Saving Data

You can create a data handler to handle the loading of data into the data model and the saving of the data model into the PCD. A data handler provides the following methods:

  • loadData(): Loads data into the data model.

  • saveData(): Stores the data model into the PCD.

For more information on creating a data handler, see Step 3: Creating a Data Handler.

Reloading Data

The editor framework calls loadData() on the data handler when the editor is first launched, and whenever the user clicks Refresh. If you need the data reloaded at any other time, call setLoadDataRequired() on the editor context and pass the value true.

Syntax Syntax

  1. context.setLoadDataRequired(true);
End of the code.
Dirty State

To indicate to the editor that data has changed and, therefore, should be saved, set the dirty state to true. This enables the Save button, and also triggers a dialog for saving changes if the administrator clicks Close.

Set the dirty state by calling setDirty() on the editor context, as follows

Syntax Syntax

  1. context.setDirty(true);
End of the code.