Wednesday 26 August 2015

Triggering of Hook methods in special cases in Webdynpro

Pre-requisite: You must be comfertable with the concept and working of hook methods. If not Click Here.

So now as hook methods are no more an alien term to you, we will see the triggering of hook methods in few special cases.

Case 1: When user click on some button, but after action control remains on the same screen.

                        WDDOBEFOREACTION
                        ONACTION<Action_name>

                        WDDOAFTERACTION
                        WDDOBEFORENAVIGATION (COMPONENTCONTROLLER)
                        WDDOMODIFYVIEW
                        WDDOPOSTPROCESSING (COMPONENTCONTROLLER)

Case 2: When user click on some button and a next view gets open.

                        WDDOBEFOREACTION (of first view)
                        ONACTION<Action_name>
                        WDDOAFTERACTION (of first view)
                        WDDOBEFORENAVIGATION (COMPONENTCONTROLLER)
                        WDDOINIT (of next view, because that view is being loaded
                                                  for the first time)
                        WDDOMODIFYVIEW (of next view)
                        WDDOPOSTPROCESSING (COMPONENTCONTROLLER)
Case 3: When user click on some button and a popup gets open as a result.
                        WDDOBEFOREACTION (of first view)
                        ONACTION<Action_name>
                        WDDOAFTERACTION (of first view)
                        WDDOBEFORENAVIGATION (COMPONENTCONTROLLER)
                        WDDOMODIFYVIEW (of first view)
                        WDDOPOSTPROCESSING (COMPONENTCONTROLLER)
                        WDDOINIT (of popup view)
                        WDDOBEFORENAVIGATION (COMPONENTCONTROLLER)
                        WDDOMODIFYVIEW (of first view)
                        WDDOMODIFYVIEW (of popup view)
                        WDDOPOSTPROCESSING (COMPONENTCONTROLLER)

Case 4: When user clicks on OK button of popup screen. On click of this button popup screen will disappear and control will come to the main screen. This OK button’s action will be handled in main screen. So in this scenario.
                        WDDOBEFOREACTION (of first view)
                        WDDOBEFOREACTION (of popup view)
                        ONACTIONOK (action method of OK button, which is in first view)
                        WDDOAFTERACTION (of first view)
                        WDDOAFTERACTION (of popup view)
                        WDDOBEFORENAVIGATION (COMPONENTCONTROLLER)
                        WDDOMODIFYVIEW (of first view)
                        WDDOMODIFYVIEW (of popup view)
                        WDDOPOSTPROCESSING (COMPONENTCONTROLLER)
                        WDDOEXIT (of popup view)
                        WDDOBEFORENAVIGATION (COMPONENTCONTROLLER)
                        WDDOMODIFYVIEW (of first view) : This is again coming into picture
                                  because after popup view finally control is going into main view.
                        WDDOPOSTPROCESSING (COMPONENTCONTROLLER)

Happy Learning  :)

Tuesday 25 August 2015

Hook methods: execution and usage in Webdynpro

In simple words, Hook methods in Webdynpro are special methods that come automatically once you create a component, window, view. Also hook methods will come into picture at different point of time during execution of webdynpro component.

How we can differentiate hook methods from normal user defined methods?
    By looking at the method's name. All the hook methods start with 'WDDO'

What all hook methods are available to us?
     Hook methods are specific to component, window and view. One can easily find out by going into 'Methods' tab in respective part. For your easy access, below is the information.

What is the use of Hook methods?
That is Good question, but before that we should be aware of which hook method comes into picture at what time and in which order.

One can easily figure out that by putting break points in all hook methods and test the webdynpro application. Control will stop at different break points and we can find out the exact order of execution of different hook methods. BUT :) for your easy reference, below is the information.

WDDOINIT (COMPONENTCONTROLLER): will be called only once when component is loaded
WDDOINIT (Window): will be called once each time when window is getting loaded.
WDDOBEFORENAVIGATION (COMPONENTCONTROLLER): Every time before WDDOMODIFY or WDDIINIT of a view is called
WDDOINIT (view): will be called only once each time view is gettinig loaded.
WDDOMODIFYVIEW (View): will be called every time either view is getting loaded for first time
or user does some action or you are coming back to view from some other view.
WDDOPOSTPROCESSING (COMPONENTCONTROLLER): Every time after WDDOMODIFY or WDDIINIT of a view is called.

After this you will be able to see the first view of your WD application. Other hook methods will come into existence upon some user action. If you try to close the WD application, below hook methods will be called.

WDDOEXIT (View)
WDDOEXIT (COMPONENTCONTROLLER)


So coming back to the question on the usage of hook methods, now we can quickly understand it.

We can make use of WDDOINIT for initialisation sort of work and WDDOEXIT for clearing the variables.

WDDOMODIFY is highly recommendable for making changes in the view before it is displayed . If we are trying to do some dynamic changes to the view, this is the place. Also WDDOMODIFY method has a parameter named VIEW in it which holds the reference if the current view, so we can use this parameter while doing dynamic changes to the view.

Happy Learning :)