Events PowerPoint PPT Presentation

presentation player overlay
1 / 8
About This Presentation
Transcript and Presenter's Notes

Title: Events


1
Events
2
Events
  • Events are used to allow a controller to inform
    another controller (whether its in the same
    component or another component) that something
    has occurred
  • Events are particularly important in situations
    in which communication must take place against
    the direction of a usage relationship

3
Events
Parent component uses the component interface
controller of thechild component giving the
ability toexecute methods in the
componentinterface controller.
Parent Component
ComponentController
Usage
ComponentInterface Controller
Child Component
However, if the child component cannotexecute
code in the parent componentso if it needs to
communicate with theparent component it must
raise an eventin its component interface
controllerto which the component controller of
theparent component subscribes. This causesa
an event handler method in the parentcomponent
controller to execute.
ComponentController
4
Events
  • Events can be defined for all controllers except
    view controllers and interface view controllers
  • Events cannot be defined in view controllers
    because they have no public interface to make the
    events available
  • Controllers can subscribe to the events defined
    in other controllers if a usage relationship is
    established
  • When the event is fired, an event handler method
    executes in the subscribing controller

5
Firing an Event
  • Event is defined in controller A
  • Method is created in controller A which fires the
    event by executing the code wdThis.wdFireltevent
    namegt()
  • Method can be executed by an action or by some
    other code
  • Controller that subscribes to the event executes
    and event handler when the event is fired
  • Parameters can be passed

6
Event Handler
7
Event firing
public void fireEvent( java.lang.String text )
//_at__at_begin fireEvent()
wdThis.wdFireEventAnEvent(text) //_at__at_end
public void reactToComponentEvent(com.sap.tc.webd
ynpro.progmodel.api.IWDCustomEvent wdEvent,
java.lang.String text ) //_at__at_begin
reactToComponentEvent(ServerEvent) //Whatever
code is required to handle event //_at__at_end
8
Action Events
public void onActionGo( com.sap.tc.webdynpro.progm
odel.api.IWDCustomEvent wdEvent )
//_at__at_begin onActionGo(ServerEvent)
wdThis.wdFirePlugToResultView() //_at__at_end
public void onPlugfromStartView( com.sap.tc.webdy
npro.progmodel.api.IWDCustomEvent wdEvent )
//_at__at_begin onPlugfromStartView(ServerEvent) Stri
ng headerText "Congratulations " headerText
wdContext.currentContextElement().getHeaderText
() headerText "!" wdContext.currentContextE
lement().setHeaderText(headerText) //_at__at_end
Write a Comment
User Comments (0)
About PowerShow.com