You have to implement methods that initialize the runtime view components the first time they are called. In each of these methods you should specify the parameters that need to be handed over from the component itself to the view context (for example, information about process instance, current phase and activity, and so on).
This method is used for the initialization of content components.
The example below assumes that you have also defined additional elements in your context, such as a process node and a process instance attribute.
Initializing a Content Component |
public void setContentComponent(com.sap.caf.eu.gp.rtcontent.api.IGPRTContentComponent contentComponent) { // get the current context element IPublicCContentOverviewInterface.IContextElement ctxElem = wdContext.currentContextElement(); // set the content component wdContext.currentContextElement().setContentComponent(contentComponent); if(contentComponent!=null){ // get the process instance of the content component IGPProcessInstance instance = contentComponent.getProcessInstance(); // set process instance of the current process element of the context wdContext.currentProcessElement().setProcessInstance(instance); // get the title of the content component String title = contentComponent.getTitle(); // set the title of the context element ctxElem.setViewTitle(title); ... } } |
This method is used for the initialization of contextual panel components.
The example below assumes that you have also defined additional elements in your context, such as process, block and activity nodes with their respective instance attributes.
Initializing a Contextual Panel Component |
public void setCtxPanelComponent(com.sap.caf.eu.gp.rtcp.api.IGPRTCPComponent ctxPanelComponent) { // get the current process element IPublicCInfoCONavInterface.IProcessElement processElem = wdContext.currentProcessElement(); // set the contextual panel component wdContext.currentContextElement().setCtxPanelComponent(ctxPanelComponent); // get the current instance, phase and activity of the component IGPProcessInstance currentProcess = ctxPanelComponent.getProcessInstance(); IGPBlockInstance currentPhase = ctxPanelComponent.getSelectedPhase(); IGPActivityInstance currentActivity = ctxPanelComponent.getSelectedActivity(); // set the instance, phase and activity of the process element processElem.setProcessInstance(currentProcess); processElem.setCurrentPhase(currentPhase); processElem.setCurrentActivity(currentActivity); ... } |
The refresh() method used for the contextual panel components updates the view context with information retrieved from the current contextual panel component.
Updating the Contextual Panel Component |
public void refresh() { // get the current process element IPublicCInfoCONavInterface.IProcessElement processElem = wdContext.currentProcessElement(); // get the current contextual panel component IGPRTCPComponent = (IGPRTCPComponent) wdContext.currentContextElement().getCtxPanelComponent(); // get the current instance, phase and activity of the component IGPProcessInstance currentProcess = ctxPanelComponent.getProcessInstance(); IGPBlockInstance currentPhase = ctxPanelComponent.getSelectedPhase(); IGPActivityInstance currentActivity = ctxPanelComponent.getSelectedActivity(); // set the instance, phase and activity of the process element processElem.setProcessInstance(currentProcess); processElem.setCurrentPhase(currentPhase); processElem.setCurrentActivity(currentActivity); ... } |