Chinaunix首页 | 论坛 | 博客
  • 博客访问: 203389
  • 博文数量: 54
  • 博客积分: 2056
  • 博客等级: 大尉
  • 技术积分: 568
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 12:07
文章分类

全部博文(54)

文章存档

2014年(1)

2013年(1)

2012年(1)

2011年(2)

2010年(1)

2009年(11)

2008年(28)

2007年(9)

我的朋友

分类:

2008-06-03 08:59:38

IS HTMLB                          BUTTON

Functionality

This BSP element implements the classical GUI element of a pushbutton. When a user clicks on a pushbutton, a predefined action is triggered.

If you click on a pushbutton, this triggers the event CLICK. You can use the associated onClick event handler to execute a predefined task. The event CLICK can be dynamically activated or deactivated with the attribute disabled. If a pushbutton is deactivated, it will not react to use reactions.
A button element has a text label (attribute text) and can also provide quick info (attribute tooltip).
The size and appearance of a pushbutton is defined using style sheets. The attribute design enables you to choose between standard size and small size for the pushbutton. For example, you  can use these to indicate the importance of the pushbuttons.

Attributes

Name Mandatory Description
id Unique name that identifies the BSP element. This attribute is used in event handling and in data handling.
text Use this attribute to define the text you want to display on the button.
tooltip Use this attribute to define the quick info text that is displayed when the cursor is moved over the button.
onClick Use this attribute to set the event that is called when the pushbutton is selected. An event is then sent to the server, which sends back the reference in a parameter. Then the reference can be processed further.
onClientClick Use this attribute to set a client-side event handler that is called, if the pushbutton is clicked.
width Use this attribute to define the width of the pushbutton.
design Use this attribute to specify the current design for rendering the pushbutton. Possible values are: STANDARD (default value), EMPHASIZED, SMALL.
disabled Use this attribute to specify whether the pushbutton can be clicked to trigger the click event.

Example

<%@ page language="abap"%>
<%@ extension name="htmlb" prefix="htmlb"%>



  
     

                                  text          = "standard"
       />


                                  text          = "Emphasized button"
                           tooltip       = "Quick info: Please click me"
                           onClick       = "MyButtonClick"
                           design        = "emphasized"
       />


                                  text          = "Small button with fixed size"
                           tooltip       = "Quick info: Please click me"
                            onClientClick = "alert('myButton3 Clicked')"
                           design        = "small"
                           width         = "300"
      />

    



Note
See also BSP application SBSPEXT_HTMLB, page button.bsp

Event handling

A BSP element can have several events. The BSP element button only has two event handlers, onClick and onClientClick.

Generally you implement your user interface elements using a

element in the layout of your BSP, which points to the same page. In this default case, you generate the coding for the event handling in the OnInputProcessing section. Within the OnInputProcessing event handler, events can be recognized and assessed by the HTMLB BSP extension using the Event ID variable. For all HTMLB events, this variable has the value CL_HTMLB_MANAGER=>event_id. 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 in two ways. The first way involves retrieving the event data and then processing the data (usually in a large case statement). The alternative is to 'trigger' the event against an event class that was instantiated by the user.

  • Scenario 1: Gets the event and processes the data
    In this case, the HTMLB manager is called in order to obtain a reference to a generic event object of type CL_HTMLB_EVENT. You can use the attribute name and event_type on this event object to determine which type of event is available. If the element supports the attribute id, you can use the attribute id to find out which element triggered the event. To display detailed information, display the object event on an object event with the correct type, in this case a button event. You can find more information about the button event in class CL_HTMLB_EVENT_Button.
      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.
      ENDIF.
    Note
    Note that for the BSP element
  • Scenario 2:
    The interface is available for event handling. This interface contains methods for all of the BSP elements that are used in the BSP extension HTMLB and which use events.
    The event can be triggered by a user-instantiated event handler class. In this case, the event handling class can be any user-defined class that must implement and have already instantiated the interface IF_HTMLB_EVENT. You can usually use the application class, for example, to handle specific events. If you do this, the only prerequisite is that the application class must implement interface IF_HTMLB_EVENT.
    The following example uses a separate class named CL_HTMLB_EVENT_EXAMPLE 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 triggers event IF_HTMLB_EVENT~BUTTON_CLICK, which contains the additional parameter id.
    For all events that are triggered, there is the onClick attribute. This is the name that is assigned by rhe user for the event handler method.
    Caution
    All button click events for all of the buttons on the page are triggered by this one method. As a developer, ensure that you select the correct ID to determine which button is triggered.

Data Extraction for Inbound Requests

No data handling is supported for this BSP element.

Tips and Tricks

  • We recommend that you use the onClick or onClientClick event handler, since pushbuttons are of no use without them. A button element without an event handler is always returned with a deactivated status.
  • BSP element defines a "small" design. We recommend that you use the same design for input fields and pushbuttons that are related to each other functionally or semantically.
  • Pushbuttons are generally not appropriate for the Web and should therefore be avoided, if possible. You should then only use pushbuttons, if you want to transfer information or data to the server. Only use pushbuttons for navigation. Otherwise use hyperlinks. Braille equipment also has problems recognizing pushbuttons.

Further information

You can find additional information about BSP extensions in the SAP Library under .

You can find general information about BSP applications in the SAP Library under mySAP Technology Components -> SAP Web Application Server -> Web Applications (BC-MAS) -> SAP Web Application Server -> .

阅读(1009) | 评论(0) | 转发(0) |
0

上一篇:Creating New Users

下一篇:何谓 FOB

给主人留下些什么吧!~~