Skip to end of metadata
Go to start of metadata

Link to Content's target Space :

CRM WebClient UI

Applies to:

CRM WebClient UI - Generic


This wiki discusses the effect of navigation via the history buttons on the calls made for controller/context initialization.


   Arun Prakash K
Company:     Accenture
Created on:    July 12, 2010
Author(s) Bio
Arun Prakash is a Senior Programmer employed with Acccenture, working on CRM implementations.

For most of us, the DO_INT_CONTEXT is THE place where we assign default values to the context nodes and often, initialize various attributes of the controller class. The context methods really standout in the workbench tree structure and we tend to do all initializations there and it works out well most of the time. We take it for granted that this method will always be triggered when the screen is loaded and this works out well in most of the cases. However, the behavior is slightly different if the history buttons(forward and back) are used to revisit the screens. In this case, the DO_INIT_CONTEXT methods of the "outer view" controllers are suppressed. In a typical scenario, the "outer view" would be the overview page and the window controllers embedding it. For example, the outer view controllers of the opportunity overview application would be the

window controller of the Main Component - BT111M_OPPT
    Window controller of the header component - BT111H_OPPT
        View Controller of the Over view page - BT111H_OPPT/OpportunityOVViewSet

If the history buttons are used to visit this application, the context initialization would be skipped for these three controllers. The other embedded views  within the overview page have their DO_INIT_CONTExT methods called though. The skip applies only for the outer view controllers. This is deliberately done so that the screen is reloaded as it was when the user left the screen. In this case, you need only to worry if you are using the DO_INIT_CONTEXT methods of the "outer view" controllers. Again, the behavior is different if you use the history buttons to navigate between documents in the same application area(for example, different opportunity documents). You should be especially wary of this situation if you are initializing attributes for the documents in the context initialization methods. When the history button is used for navigation, an alternative method is called if you need any special handling. This is the DO_VIEW_INIT_ON_RESTORE method. Here are the typical scenarios and the method calls in each case

Normal navigation(other than using history buttons)
DO_INIT_CONTEXT - Always called
DO_VIEW_INIT_ON_ACTIVATION - Always called, after context init

Navigation via history buttons between different application areas
DO_INIT_CONTEXT - Skipped only for "outer view" controllers
DO_VIEW_INIT_ON_RESTORE - Called only for controllers for which the context initialization was skipped

Navigation via history between same application area

        In this case, there is no necessity for "regenerating" views as the view containers are already present. Only the data changes. You might want to take note of this scenario if you do your initialization based on the document data. In this case, you can make use of the ON_RESTORE method.

DO_VIEW_INIT_ON_RESTORE - Called for all controllers

Exit/Cleanup Methods

So far, we have seen about the initialization methods. What about the DO_CLEANUP_CONTEXT method? You need not worry in this case as this method is always called for all the controllers upon exit. This is to provide the application/views a way to make a clean exit and for possible data loss handling. Since the DO_VIEW_INIT_ON_ACTIVATION method is always called(with the exception of same view navigation) during the initialization phase, it is an ideal place for registering event handlers and the freeing the registrations can be done in the DO_CLEANUP_CONTEXT method.

Useful Information

Calls to DO_INIT_CONTEXT method and how navigation via history buttons affect it.