Implementing a Custom Suggestion Provider

Use

The Suggestion Provider API enables you to add and control suggestions displayed when the user enters a search term in the Search field of the Ajax Framework Page (AFP).

The API is contained in the com.sap.portal.suggestion.providers package.

Prerequisites

  • SAP NetWeaver Developer Studio is installed and started

  • In the portal's Framework Page Configuration for Ajax Framework Page , the Enable Quick Launch option is selected.

    For more information about enabling this option, see Creating and Editing a Framework Page .

Procedure

The following procedure describes how to implement and integrate a basic suggestion provider that returns a list of suggestions for a search term.

  1. In SAP NetWeaver Developer Studio, open the Enterprise Portal perspective and create a portal application project.

    For more information, see Creating a Portal Application Project .

  2. In portalapp.xml, set a sharing reference to com.sap.portal.suggestion.providers.

  3. In the portal application project, create a portal service, and add the startup property, setting it to true.

    For more information, see Creating a Portal Service .

  4. In the src.core folder, create a new class named SampleCategory that implements the ICategoryDescriptor interface.

  5. In the src.core folder, create a new class named SampleProvider that implements the ISuggestionProvider interface.

  6. To register the service, copy the following code to the init method of the service implementation class:

    To unregister the service, copy the following code to the destroy method of the service implementation class:

  7. Build and deploy your application. For more information, see Deploying a Portal Application .

  8. Enter a term in the Search field in the portal, and check that the Travel category with suggestions appears below.

More Information

Suggestion API

A client-side API that enables you to retrieve search suggestions and control their appearance