com.sap.portal.admin.editor

Interface IDataHandler

All Known Implementing Classes:
PCMDataHandler

Deprecated. As of SAP NetWeaver 2007 release, replaced by package com.sap.portal.adminstudio.workunitfwapi

public interface IDataHandler

The interface that is used to load and save data for an editor. If the data handler is not specified, a default handler is implemented. The default handler does not load any data into the editor.
These are the methods implemented in the data handler:

Load Data: In this method the data model should be created by the server data. The following example shows how to implement the method.

   public void loadData(
                        IEditorContext ctx,
                        IPrincipal principal,
                        PPLogger logger)
                        throws EditorDataException {
 
                        ctx.setProperty("details.firstName", "John");
                        ctx.setProperty("details.lastName", "Smith");
                        ctx.setProperty("details.payment", "cash");
                        ctx.setProperty("details.adress", 
                                              "26 Elm Street");
                        ctx.setProperty("payment.type", "creditCard");
                        ctx.setProperty("payment.number", "123456");
                        ctx.setProperty("payment.company", "Visa");
                        ctx.setProperty("payment.month", "08");
                        ctx.setProperty("payment.year", "2004");
                        ctx.setProperty("credit.type", "Installments");
                        ctx.setProperty("credit.number","1");

                        //setting the data for the tables
                        TableDataModel tableModel = new TableDataModel();
                        StoreableList tableModelList = (StoreableList) getTableData(ctx);
                        tableModel.setTableViewModel(tableModelList);
                        ctx.setProperty(
                               TrainsTablePane.TIME_TABLE_GENERIC_PATH,tableModel);

                        TableDataModel orderTable = new TableDataModel();
                        StoreableList orderTableList = (StoreableList)getOrderTableData(ctx);
                        orderTable.setTableViewModel(orderTableList);
                        ctx.setProperty(
                               TrainsTablePane.ORDERS_TABLE_GENERIC_PATH, 
                               orderTable);

   }
   

The first section sets the data for all the components except the table. The second section sets the table data. The getTableData and getOrderTableData methods are used to create the rows that are added to the table.

Save Data: In this method the data model data should be saved to the server. The implementation of this method is optional. The following example shows how to implement the method:

   public void saveData(
                       IEditorContext ctx,
                       IPrincipal principal,
                       PPLogger logger)
                       throws EditorDataException, 
                       EditorResourceException {

                               //apply changes according to ui fields
                               String lastName = (String)                                                                               
                               ctx.getProperty("details.lastName");

                               //retrieving the property "description" from the property editorIProperty prop = this.
                               getModifiedPropertyObject(ctx).getProperty(
                               "com.sap.portal.pcm.Description");
                               String description = prop.getValue();

                               if (lastName.equals("failed") && description.equals("last name not failed")) 
                               {

                                       ctx.getEditorResponse().addMessageKey(
                                       EditorMessageType.ERROR,"Save Failed");
                                       throw new EditorDataException("failed");
                               }
                               else
                                       super.saveData(ctx, principal, logger);
   }
   

In this example, the handler extends PCMDataHandler, enabling retrieving the values from the property editor using the getModifiedPropertyObject method. If the user enters the value failed into the lastName field, and the value last name not failed in the description property in the property editor, then when trying to save, a Save Failed error message appears.


Method Summary
 void loadData(IEditorContext ctx, com.sap.security.api.IPrincipal principal, PPLogger logger)
          Deprecated. Loads and stores the data editor context.
 void saveData(IEditorContext ctx, com.sap.security.api.IPrincipal principal, PPLogger logger)
          Deprecated. Saves the edited data for this editor.
 

Method Detail

loadData

void loadData(IEditorContext ctx,
              com.sap.security.api.IPrincipal principal,
              PPLogger logger)
              throws EditorDataException,
                     EditorResourceException
Deprecated. 
Loads and stores the data editor context. Uses the method IEditorContext.setProperty.
Note: The key for the stored data can be the same key as the user interface components target value path. In this case, the data is loaded into the editor.
For example, if there is an input field with a target value path pane1.input1, and the loaded data is setProperty("pane1.input1",data), when the editor is loaded, the input field contains the data.

Parameters:
ctx - the current editor context
principal - a security principal that loads the data
logger - a logger for sending log messages
Throws:
EditorDataException - if the data could not be loaded or there are no permissions, an end-user message is presented and read-only mode is set
EditorResourceException - if an error occurs regarding the resource for this editor, the editor framework presents an end-user message instead of the regular editor user interface

saveData

void saveData(IEditorContext ctx,
              com.sap.security.api.IPrincipal principal,
              PPLogger logger)
              throws EditorDataException,
                     EditorResourceException
Deprecated. 
Saves the edited data for this editor.

Parameters:
ctx - the current editor context
principal - a security principal that saves the data
logger - a logger for sending log messages
Throws:
EditorDataException - if the data could not be loaded or there are no permissions, an end-user message is presented and read-only mode is set
EditorResourceException - if an error occurs regarding the resource for this editor, the editor framework presents the specified end-user message instead of the regular editor user interface
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] EP-RUNTIME [sap.com] tc/ep/admin/api api EP-PIN


Copyright 2015 SAP AG Complete Copyright Notice