
For each callable object type, all object definitions are created and maintained using the same user interface. It is a wizard that leads the user through a number of screens where the different aspects of the callable object definition are set.
In the design time for your new callable object type, you must make sure that all relevant screens of the wizard are displayed, and that the data is handled in a proper way so that at the end it is consistent.
You have added the interface com.sap.caf.eu.gp.co.dt.IGPCOConfiguration to the list of implemented interfaces.
Initialize the Component and Obtain References to the Logical and Physical Callable Object
You can initialize the Web Dynpro component in different modes for creating a new callable object, editing or displaying an existing one. The framework calls the appropriate method when the user creates an object, displays or edits one. Your task is to ensure that you implement the behavior that you expect for you component in each of these modes.
| Creating the User Context in the Component Controller |
|---|
publicvoid wdDoInit() {//@@begin wdDoInit() try{IUser sapUser = WDClientUser.getCurrentUser().getSAPUser(); IGPUserContextuserCtx = GPContextFactory.getContextManager().createUserContext(sapUser); } catch (Exception ex){... } //@@end |
Used when the framework creates the component and intends to use it for the creation wizard.
Used when the framework changes the component and intends to use it for a maintenance dialog. You must make sure that the method enables read-only mode on the callable object definition. For example, you can use the method to set a Boolean parameter in the Web Dynpro context that imposes read-only access to the data.
Used when the framework changes the component and intends to use it for a display dialog.
Callable Objects and Physical Callable Objects are specializations of the more generic development objects.
A logical callable object is an instance of the com.sap.caf.eu.gp.co.api.IGPCallableObject interface. It holds the metadata for the callable object definition. The physical representation of an object is an instance of com.sap.caf.eu.gp.co.api.IGPPhysicalCallableObject . The relation between logical and physical objects is one to many. The relevant physical object is determined at runtime based on the execution context.
You must do this in the component controller.
| Initialization in the Component Controller |
|---|
publicvoid initializeCreate( com.sap.caf.eu.gp.co.api.IGPCallableObject logicalObject, com.sap.caf.eu.gp.co.api.IGPPhysicalCallableObject physicalObject ) {//@@begin initializeCreate() m_logicalCO = wdContext.currentContextElement.setLogObject(logicalObject); m_physicalCO = wdContext.currentContextElement.setPhyObject(physicalObject); //@@end } ... //@@begin others private IGPCallableObject m_logicalCO; private IGPPhysicalCallableObject m_physicalCO; //@@end } |
Display the Required Wizard Screens
Displays the select view, which is used for choosing the actual implementation or the target object of the callable object.
This view is always displayed in the callable object creation wizard.
Displays the import parameters view, which is used for either displaying or modifying the input parameters of the callable object.
Displays the export parameters view, which is used for either displaying or modifying the output parameters of the callable object.
Displays the configuration parameters view, which is used for configuring the behavior of the callable object by maintaining technical parameters.
| Methods in the Component Controller for Displaying Wizard Screens |
|---|
publicvoid showSelection( ) {//@@begin showSelection() m_screen = SCREEN_SELECTION; wdThis.wdFireEventChangeScreen(m_screen); //@@end } |
When you register your callable object type, you can choose which views are to be displayed in the wizard by setting its visibility to true. Also, if you create a structure for the input and output parameters, or add configuration properties to the physical callable object, the relevant view is displayed.
In this method you can fire an event, which is then handled in each individual screen.
This method is invoked:
This method can be called several times during the lifetime of one instance.
You can also fire the event OnSubScreenNavigation . When the visible parameter is set to true , you get a screen area with your own buttons and the framework hides its own ones.
Implement the User Interfaces
You can use a dispatcher view to process the event fired when a screen is changed and to send the wizard to the proper screen. You link the dispatcher view to the other views, and pass the required data across the views by means of plugs.
You can then use the plug handlers in the views to set context parameters and initialize the objects you need for the relevant view.
To be able to pass data correctly, you have to map Web Dynpro context parameters between the component controller and the relevant views.
| Event Handler changeScreen in the Dispatch View |
|---|
publicvoid changeScreen(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, int screen ) {//@@begin changeScreen(ServerEvent) switch (screen) {case NewCOType.SCREEN_SELECTION : wdThis.wdFirePlugToSelect(); break; case NewCOType.SCREEN_IMPORT_PARAMS : wdThis.wdFirePlugToInput(); break; case NewCOType.SCREEN_EXPORT_PARAMS : wdThis.wdFirePlugToOutput(); break; case NewCOType.SCREEN_CONFIG_PARAMS : wdThis.wdFirePlugToConfig(); break; } //@@end } |
For example, if the callable object definition requires a logical destination, you can define a configuration parameter for the destination, and set the value that the user has entered to the physical callable object instance.
You can also set any read-only properties that you define for your object - result states, and even input and output structures if they are not to be changed in the other wizard screens. You can do it in the canLeaveScreen() event handler, for example.
| Event Handler canLeaveScreen in the Select View |
|---|
//read a parameter from the context IWDAttributeInfourlAttributeInfo = wdContext.getNodeInfo().getAttribute(CONTEXT_ID_URL); ... //set the value to the physical callable object IGPPhysicalCallableObjectphysobj = wdContext.currentContextElement().getPhysicalCallableObject(); physobj.setConfigProperty("URL", url );//define a result stat physobj.addResultState("COMPLETED","Completed"); |
The framework automatically sets the root structures to the physical callable object. The example below shows which methods you can use in case you want to add a sub-structure or a parameter to the root structure. Typically however, you do not need to do it in the callable object type implementation. The callable object itself implements the logic for adding sub-structures and attributes.
| Plug Handler in the View |
|---|
try{IPrivateVInput.IContextElement ctxtElement = wdContext.currentContextElement(); // retrieve a reference to the callable object from the context IGPCallableObject logobj = ctxtElement.getCallableObject(); //read the root input structure and add an attribute IGPStructureInfo inputStructure = logobj.getInputParameters(); IGPAttributeInfo inattr = inputStructure.addAttribute("parameter", IGPAttributeInfo.BASE_STRING);inattr.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_0_1); // read the root output structure and add an attribute IGPStructureInfo outputStructure = logobj.getOutputParameters(); IGPAttributeInfo outattr = outputStructure.addAttribute("parameter", IGPAttributeInfo.BASE_STRING);//set the structures to the physical object IGPPhysicalCallableObject physobj = ctxtElement.getPhysicalCallableObject(); physobj.setInputParameters(inputStructure); physobj.setOutputParameters(outputStructure); } |
Once you have set the different aspects of the callable object definition, you can implement the runtime part of the callable object type.
More information: Implementing the Runtime for a New Callable Object Type