This file contains example source code for the weblog: BSP Programming: Handling HTMLB Events https://weblogs.sdn.sap.com/pub/wlg/648 Please refer to the weblog for details on how to apply this sample code. Example 1: handlingHtmlbEvents.BSP ================================== Page Attributes --------------- sflight TYPE FLIGHTTAB vIndex TYPE I vIndex_next_disabled TYPE STRING vIndex_prev_disabled TYPE STRING vSize TYPE STRING Layout ------ <%@ extension name="htmlb" prefix="htmlb"%> <%@ extension name="xhtmlb" prefix="xhtmlb"%> OnCreate -------- SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE sflight UP TO 25 ROWS. vSize = '7'. vIndex_prev_disabled = 'TRUE'. vIndex_next_disabled = 'FALSE'. OnInputProcessing ----------------- DATA: pager TYPE REF TO cl_xhtmlb_pager. pager ?= cl_htmlb_manager=>get_data( request = request name = 'xhtmlb:pager' id = 'pager' ). vindex = pager->vindex. DATA: event TYPE REF TO if_htmlb_data. event = cl_htmlb_manager=>get_event_ex( request ). IF event IS NOT INITIAL AND event->event_name = xhtmlb_events=>buttongroup AND event->event_type = xhtmlb_events=>buttongroup_click. CASE event->event_defined. WHEN 'prev_page'. vindex = vindex - vsize. IF vindex < 1. vindex = 1. ENDIF. WHEN 'next_page'. vindex = vindex + vsize. IF vindex >= LINES( sflight ). vindex = LINES( sflight ) - vsize + 1. ENDIF. ENDCASE. ENDIF. DATA: barrier TYPE I. barrier = LINES( sflight ) - vSize. IF vindex > barrier. vindex_next_disabled = 'TRUE'. ELSE. vindex_next_disabled = 'FALSE'. ENDIF. IF vindex <= vsize. vindex_prev_disabled = 'TRUE'. ELSE. vindex_prev_disabled = 'FALSE'. ENDIF. Example 2: handlingHtmlbEvents.BSP using CL_SDN_HANDLING_HTMLB_EVENTS with IF_*HTMLB_EVENTS =========================================================================================== Page Attributes --------------- handler TYPE REF TO CL_SDN_HANDLING_HTMLB_EVENTS Layout ------ <%@ extension name="htmlb" prefix="htmlb"%> <%@ extension name="xhtmlb" prefix="xhtmlb"%> OnInputProcessing ----------------- DATA: pager TYPE REF TO cl_xhtmlb_pager. pager ?= cl_htmlb_manager=>get_data( request = request name = 'xhtmlb:pager' id = 'pager' ). CREATE OBJECT handler EXPORTING vIndex = pager->vIndex. cl_htmlb_manager=>dispatch_event_ex( request = request page_context = page_context event_handler = handler ). OnInitialization ---------------- IF handler IS INITIAL. CREATE OBJECT handler. ENDIF. Example 2: CL_SDN_HANDLING_HTMLB_EVENTS with IF_*HTMLB_EVENTS ============================================================= class CL_SDN_HANDLING_HTMLB_EVENTS definition public create public . public section. interfaces IF_HTMLB_EVENT. interfaces IF_HTMLB_EVENTS. interfaces IF_XHTMLB_EVENTS. data VINDEX type I . data VINDEX_NEXT_DISABLED type STRING . data VINDEX_PREV_DISABLED type STRING . data VSIZE type STRING . data SFLIGHT type FLIGHTTAB . methods CONSTRUCTOR importing !VINDEX type I default 1 . endclass. class CL_SDN_HANDLING_HTMLB_EVENTS implementation. method CONSTRUCTOR. SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE me->sflight UP TO 25 ROWS. me->vIndex = vIndex. me->vSize = '7'. DATA: barrier TYPE I. barrier = LINES( sflight ) - vSize. IF vindex > barrier. vindex_next_disabled = 'TRUE'. ELSE. vindex_next_disabled = 'FALSE'. ENDIF. IF vindex <= vsize. vindex_prev_disabled = 'TRUE'. ELSE. vindex_prev_disabled = 'FALSE'. ENDIF. endmethod. method IF_XHTMLB_EVENTS~BUTTONGROUP_CLICK. CASE buttonClicked. WHEN 'prev_page'. vindex = vindex - vsize. IF vindex < 1. vindex = 1. ENDIF. WHEN 'next_page'. vindex = vindex + vsize. IF vindex >= LINES( sflight ). vindex = LINES( sflight ) - vsize + 1. ENDIF. ENDCASE. DATA: barrier TYPE I. barrier = LINES( sflight ) - vSize. IF vindex > barrier. vindex_next_disabled = 'TRUE'. ELSE. vindex_next_disabled = 'FALSE'. ENDIF. IF vindex <= vsize. vindex_prev_disabled = 'TRUE'. ELSE. vindex_prev_disabled = 'FALSE'. ENDIF. endmethod. endclass. Example 3: CL_SDN_HANDLING_HTMLB_EVENTS using onClick Methods ============================================================= class CL_SDN_HANDLING_HTMLB_EVENTS definition public create public . public section. data VINDEX type I . data VINDEX_NEXT_DISABLED type STRING . data VINDEX_PREV_DISABLED type STRING . data VSIZE type STRING . data SFLIGHT type FLIGHTTAB . methods CONSTRUCTOR importing !VINDEX type I default 1 . methods TABLEPAGER importing !EVENT_OBJECT type ref to IF_HTMLB_DATA . endclass. class CL_SDN_HANDLING_HTMLB_EVENTS implementation. method CONSTRUCTOR. SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE me->sflight UP TO 25 ROWS. me->vIndex = vIndex. me->vSize = '7'. DATA: barrier TYPE I. barrier = LINES( sflight ) - vSize. IF vindex > barrier. vindex_next_disabled = 'TRUE'. ELSE. vindex_next_disabled = 'FALSE'. ENDIF. IF vindex <= vsize. vindex_prev_disabled = 'TRUE'. ELSE. vindex_prev_disabled = 'FALSE'. ENDIF. endmethod. method TABLEPAGER. CASE event_object->event_defined. WHEN 'prev_page'. vindex = vindex - vsize. IF vindex < 1. vindex = 1. ENDIF. WHEN 'next_page'. vindex = vindex + vsize. IF vindex >= LINES( sflight ). vindex = LINES( sflight ) - vsize + 1. ENDIF. ENDCASE. DATA: barrier TYPE I. barrier = LINES( sflight ) - vSize. IF vindex > barrier. vindex_next_disabled = 'TRUE'. ELSE. vindex_next_disabled = 'FALSE'. ENDIF. IF vindex <= vsize. vindex_prev_disabled = 'TRUE'. ELSE. vindex_prev_disabled = 'FALSE'. ENDIF. endmethod. endclass.