Registering Web Dynpro Components and Runtime Views

Use

Before you can use the content and contextual panel components you have created, you need to register them as Web Dynpro components. Consequently, you use these Web Dynpro components when you create your runtime view configuration.

The procedure below offers only a temporary registration of runtime view components and configurations, using an application.

You can also register these components using an HTTP servlet. For more information, see Registering Runtime Views Using Servlets .

Prerequisites

  • You have created a content component or a contextual panel component. For more information, see Creating Custom Runtime Views Using the GP APIs .
  • If you work with the SAP NetWeaver Developer Studio (NWDS), you need to place the registration code for the components and view configuration in the wdDoInit() method of the component controller.

Procedure

  1. Create an
    IGPWDComponent
    component by specifying the necessary attributes.

Registering a Content Component as a Web Dynpro Component
importcom.sap.caf.eu.gp.wdcomponent.api.IGPWDComponentManager;
importcom.sap.caf.eu.gp.wdcomponent.api.GPWDComponentFactory;
importcom.sap.caf.eu.gp.wdcomponent.api.IGPWDComponent;
 
// instantiate the WDComponent manager
IGPWDComponentManagermgr = GPWDComponentFactory.getWDComponentManager();
// get the resource accessor (user-defined)
ContentPaneResourceAccessoraccessor = new ContentPaneResourceAccessor(                   "com.sap.caf.eu.gp.runtime.resource.ContentPane");
// register the content component as a WDComponent
IGPWDComponentcontentComponent = mgr.createWDComponent(
                        // component ID, not null, must be unique
                         "MyOwnContentPane",
                         // component name
                         "com.sap.caf.eu.gp.runtime.view.CContentPane",
                        // DC name
                         "sap.com/caf~eu~gp~runtime~view",
                         accessor,
                        // frame title key
                         "FrameTitle"
                        );
  1. Create and register a view configuration.

Creating a Runtime View
importcom.sap.caf.eu.gp.rtview.api.GPRTViewFactory;
importcom.sap.caf.eu.gp.rtview.api.IGPRTView;
importcom.sap.caf.eu.gp.rtview.api.IGPRTViewManager;
importjava.util.Enumeration;
importcom.sap.tc.webdynpro.services.sal.um.api.WDUMException;
importcom.sap.caf.eu.gp.exception.api.GPEngineException;
importcom.sap.caf.eu.gp.exception.api.GPInvocationException;
 
IGPRTViewManagervManager = GPRTViewFactory.getRTViewManager();
booleanisRegistered = false;
   
try{
   String viewId = "MyViewConfiguration";
   // check if view is already registered:
   Enumeration rViews = vManager.getRTViews();
   while (rViews.hasMoreElements()){
      IGPRTView view = (IGPRTView)rViews.nextElement();
      if (view.getRTViewId().equals(viewId)){
         isRegistered = true;
         break;
      }
   }
   // if it is not registered
   if (isRegistered == false) {
      // create a WD component
      // -- place registration code from step 1 here --
      // create a runtime view configuration
      IGPRTView viewConfiguration = vManager.createRTView(
                          // view ID, not null, must be unique
                           viewId,
                          // default WD content component, created above
                           contentComponent,
                           accessor,
                          // the title for the view switch
                           "PaneTitle",
                          // the tool tip for the view switch
                           "PaneDescription",
                          // enable this view as mandatory
                           IGPRTView.MANDATORY_GROUP_PROCESS_STRUCTURE,
                          // do not set it as default view
                           false
                          );
     // register the view
      vManager.registerRTView(viewConfiguration);
   }
}catch (WDUMException ex) {
}catch (GPInvocationException ex) {
}catch (GPEngineException ex) {
}
  1. Add contextual panel components to the view configuration.

Adding Contextual Panel Components to the Runtime View
// register the contextual panel component as a WDComponent
IGPWDComponentctxPanelComponent = mgr.createWDComponent(
                        "MyOwnContextualComponent",
                         // component name
                         "com.sap.caf.eu.gp.runtime.view.CtxNavigation",
                        // DC name
                         "sap.com/caf~eu~gp~runtime~view",
                         accessor,
                        // frame title key
                         "Title"
                        );
// add the component to the view
viewConfiguration.addCPComponent(ctxPanelComponent);
  1. Create, build, deploy and run the application to register the runtime view configuration.