Show TOC Start of Content Area

Procedure documentation Developing Handlers  Locate the document in its SAP Library structure

A handler enables you to define code that can be executed by uploading a properly formatted XML file.

For example, in order to run code to create an iView, the portal comes with a handler – of type com.sapportals.portal.iview – that enables administrators to create an iView by uploading an XML file.

When an XML file is uploaded, the specified handler classes are called in two phases:

      Validation: The doValidate() method of each handler is called to make sure the XML for each handler is properly coded and all mandatory attributes exist. The method returns true if the XML is validated, otherwise false.

      Execution: The doExecute() and doClean() methods of each handler are called as needed, based on the mode attribute of the <GenericCreator> tag.

How to Create a Handler

To create a handler for the XML Content and Actions features, do the following:

      Create a class that implements the IHandlerinterface, as described below.

      Register the handler, as described in Registering Handlers.

Procedure

...

       1.      Create a new class that implements com.sap.portal.genericcreator.handlers.IHandler.

       2.      Implement the following methods:

       doValidate(): Called once for each <Context> or <Action> tag that specifies the handler. Validate all necessary parameters in this method.

If any call to doValidate() returns false, the entire XML file is not run, that is, the doExecute() and doClean() methods are not called.

       doExecute(): Called once for each <Context> or <Action> tag that specifies the handler, if the mode attribute of the <GenericCreator> tag is set to execute.

       doClean(): Called once for each <Context> or <Action> tag that specifies the handler, if the mode attribute of the <GenericCreator> tag is set to clean.

Each method is passed information about the XML attributes in the <Context> or <Action> tag for which the handler was called, as well as any attributes specified in a nested <Attributes> tag. For more information, see Accessing Attributes.

Each method also is passed information about the user.

 

End of Content Area