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.
● 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 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.
...
1. Create an IGPWDComponent component by specifying the necessary attributes.
Registering a Content Component as a Web Dynpro Component |
import com.sap.caf.eu.gp.wdcomponent.api.IGPWDComponentManager; import com.sap.caf.eu.gp.wdcomponent.api.GPWDComponentFactory; import com.sap.caf.eu.gp.wdcomponent.api.IGPWDComponent;
// instantiate the WDComponent manager IGPWDComponentManager mgr = GPWDComponentFactory.getWDComponentManager(); // get the resource accessor (user-defined) ContentPaneResourceAccessor accessor = new ContentPaneResourceAccessor( "com.sap.caf.eu.gp.runtime.resource.ContentPane"); // register the content component as a WDComponent IGPWDComponent contentComponent = 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" ); |
2. Create and register a view configuration.
Creating a Runtime View |
import com.sap.caf.eu.gp.rtview.api.GPRTViewFactory; import com.sap.caf.eu.gp.rtview.api.IGPRTView; import com.sap.caf.eu.gp.rtview.api.IGPRTViewManager; import java.util.Enumeration; import com.sap.tc.webdynpro.services.sal.um.api.WDUMException; import com.sap.caf.eu.gp.exception.api.GPEngineException; import com.sap.caf.eu.gp.exception.api.GPInvocationException;
IGPRTViewManager vManager = GPRTViewFactory.getRTViewManager(); boolean isRegistered = 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) { } |
3. Add contextual panel components to the view configuration.
Contextual panel components can be more than one and should be attached to the view configuration after it is created.
Adding Contextual Panel Components to the Runtime View |
// register the contextual panel component as a WDComponent IGPWDComponent ctxPanelComponent = 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);
|
4. Create, build, deploy and run the application to register the runtime view configuration.