How to use Web Dynpro UI element – “Timed Trigger ” with Static and Dynamic Programming
Timed Trigger UI element triggers automatically and periodically an event.To specify the periodicity,we have to use its delay property. As we have mentioned above, most of the UI element properties can be bound. Hereunder, we show a table with some of the TimedTrigger properties that can be bound and the attribute type in case the property is bindable (Table)
At every 5 s, we trigger an event that uses a Function Module to generate a random number under 1,000.In context view, we create a node named COUNTER,cardinality 1...1,Singleton that has an attribute COUNTER_TT of i type.
We have used an action named TRIGGER to specify the action to be triggered after the specified delay 5(Listing).
DATA lr_node TYPE REF TO if_wd_context_node.
DATA ls_data TYPE wd_this->element_counter.
DATA lv_step TYPE i.
lr_node = wd_context->get_child_node('COUNTER').
CALL FUNCTION 'GENERAL_GET_RANDOM_INT'
range = 1000
random = lv_step.
ls_data-counter_tt = lv_step.
The Function Module GENERAL_GET_RANDOM_INT has an import parameter named RANGE of i type and an exporting parameter named RANDOM of i type. This function returns the random value with 0(RANDOM)(RANGE) At runtime.
RUNTIME CLASS: CL_WD_TIMED_TRIGGER
As we have seen,by using the wdDoModifyView( )Hook method we can dynamically create an UI element. The same properties, events and aggregations as in the View Designer are available.
Hereunder,we present a table showing the correspondence between the view designer name and the runtime name, with the proper types,in case of dynamic programming of a TimedTrigger UI element (Table).
The implementation of a dynamic TimedTrigger UI element contains the following statements (Listing).
DATA lr_timed_trigger TYPE REF TO cl_wd_timed_trigger.
lr_timed_trigger = cl_wd_timed_trigger=>new_timed_trigger(id ='TIMED_TRIGGER'delay = 5 on_action ='TRIGGER').