二维码

[教程] CREATING SEARCH EVENT HANDLER

Twilight发表于 2015-12-03 00:25Twilight 最后回复于 2015-12-03 00:25 [复制链接] 2037 0

We have a view where we can enter search criteria. However, we did not write any code to use these selection criteria and based on the selection criteria, we need to fetch results from the database.

Let us provide one search button to the user and create one event handler to be triggered when user clicks on search button.

CREATING BUTTON:

We use THTMLB: button tag to create buttons on the screen.
Go to the SearchPage.htm and add the following code to add the button.
  1. <thtmlb:button id      = "btn1"
  2.                onClick = "search"
  3.                text    = "search" />
复制代码

Here, we have given ‘search’ as a value to the onClick property of button. So clicking on button will trigger the event handler. Text is nothing but the text that appears on the button.

CREATING EVENT HANDLERS:
Event handler name is case sensitive.

go to the component browser and click on the view and then right click on the event handler in the right panel. Choose create.
search event 1.jpg

In the next popup, give the event name as ‘search’ and choose continue. Framework will create one event handler with name EH_ONSEARCH.  Now we need to code in the event handler.
search event 2.jpg

We need to know one important method at this point of time.
Go to the view implementation class ->properties tab and open the super class by double clicking on it.
search event 3.jpg

Go to the methods section. We can the method with name DO HANDLE EVENT. This is method every time called first for any event handler. From this, the control will be delegated to corresponding event handler depending on the event name.
search event 4.jpg

We can see the based on event name, corresponding event handler is called inside the case statement.
So we will look at this method by placing break point here, if any event handler is not working (control is not reaching to our event handler).

Now you can place a break point (external) here and test the application. When we click on the search button, control will come to this method and from this method, it will go our search event handler.
We will fetch the data and display it in the next chapter, A little complex thing.
回复

使用道具 举报

快速回帖

本版积分规则
您需要登录后才可以回帖 登录 | 注册有礼

快速回复 返回顶部 返回列表