!--a11y-->
Defining Event Handlers for the First Page 
Use
Now that you have specified the events in the layout that are executed when the user chooses certain buttons, you need to define the event handlers.
In this example you simply need the event handler for processing OnInputProcessing.
Event CLICK is triggered if the user clicks on a pushbutton. You can use the corresponding
onClick event handler to execute a predefined task. You can dynamically activate or deactivate the CLICK event with the attribute disabled. If a pushbutton is deactivated, it no longer reacts to the user’s actions.Event Handling with HTMLB Element button
A BSP element can have many events. BSP element button has only two event handlers,
onClick and onClientClick. In the example, only onClick is used.You usually realize your user interface elements with a <
form> element in the layout of your BSP, which refers back to the same page. This is the same here. In the default case, you create the coding for event handling in the OnInputProcessing section. Within the OnInputProcessing event handler, the event ID variable can recognize and evaluate events from the HTMLB BSP extension. For all HTMLB events, this variable has the value CL_HTMLB_MANAGER=>event_id. The events are usually handled according to this framework:IF event_id = CL_HTMLB_MANAGER=>EVENT_ID.
… handle HTMLB event…
ENDIF.
You can implement event handling for
HTMLB events in two ways: The first technique involves retrieving event data and then processing this data (usually in a large case statement). The alternative is to "fire" the event at a user-instantiated event class.In this case the HTMLB manager is called in order to obtain a reference to a generic event object of type
DATA: event TYPE REF TO CL_HTMLB_EVENT.
event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
IF event->name = 'button' AND event->event_type = 'click'.
DATA: button_event TYPE REF TO CL_HTMLB_EVENT_BUTTON.
button_event ?= event.

Note that for BSP element
button and the onClick events, the event class is CL_HTMLB_EVENT_BUTTON.Interface
The event can be fired at a user-instantiated event handler class. In this example, the event handling class can be any user-defined class, provided that it implements interface
IF_HTMLB_EVENT and is already instantiated. You can usually use the application class, for example, for handling specific events. The only requirement is that the application class implements interface IF_HTMLB_EVENT.In the following example, a separate class called
CL_HTMLB_EVENT_EXAMPLE is used for event handling:DATA: event_handler TYPE REF TO CL_HTMLB_EVENT_EXAMPLE.
CREATE OBJECT event_handler.
CL_HTMLB_MANAGER=>dispatch_event(
request = runtime->server->request
event_handler = event_handler
page_context = page_context
).
The button element fires event
IF_HTMLB_EVENT~BUTTON_CLICK that also contains the additional parameter id.The
onClick attribute is available for all triggered events. This is the name assigned by the user for the event handler method.
All
BUTTON click events are fired by this one method for all of the buttons on the page. As a developer, ensure that you choose the correct ID to decide which button was triggered.See also:
Defining the Event Handler for the Entry Page of the Second TutorialProcedure
|
CLASS CL_HTMLB_MANAGER DEFINITION LOAD. * Optional: test that this is an event from HTMLB library. * See if upload is triggered from button event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ). IF event->name = 'button' AND event->event_type = 'click'. DATA: button_event TYPE REF TO CL_HTMLB_EVENT_BUTTON. button_event ?= event. ENDIF. CASE event->id. WHEN 'search'. DATA: lname TYPE REF TO CL_HTMLB_INPUTFIELD. lname ?= CL_HTMLB_MANAGER=>GET_DATA( WHEN 'authorlist'. WHEN others. ENDCASE. ENDIF. |
Now go on to the