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.
<thtmlb:button id = "btn1"
onClick = "search"
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.