Sunday, 1 December 2013

8. Adding Event Handler to Advanced Search View

Let's add Event handler to 'AdvSearchView'.

Goto view 'AdvSearchView', double click on the view. 

First Let's declare a button in AdvSearchView.htm file to view it. Goto 'AdvSearchView' and add the code at the bottom.

Code  as :



Save and activate it.

Now test you application. Search button appears in the screen. but, it is not helping us to fetch the details.

When you(user) clicks on 'search' button, technically it is called as 'Action'.

So, let me continue like... When user perform a Action(Here Clicking on 'Search' button). The request will go to our UI Component, and this Action will raise a Event, and this event should be handled by the 'Event Handler'. This is how Event handler follows Event, Event follows Action.

So, we need to define event handler with name  * 'search'. 

Let's do it. Select 'Event Handler' -> right click -> 'Create'.

















Provide, event handler name as 'search'. 
Note: the name of event handler is case sensitive, provide the same name of the code that we have added in .htm file(Onclick = "search").






Wizard will create a method 'EH_ONSEARCH'.

You have created a event handler 'search' on 'AdvancedSearchView'. now, we need to perform tasks that we expect once we click on 'Search' button.

What is expected : Need to retrieve resulted data and pass it to 'ResultView'. Passing the values to 'ResultView' is not possible b,cos of framework limitations.

What we can do is to store the result data, where............. Storage device is Context Node' and what should be it's structure, it should be Mobile. So, we need to create a Context Node with name 'ResultObject' of type 'Mobile' BOL Entity.

Let's Create a Context node.

Expand 'Context' -> Select 'Context Nodes' -> Right Click 'Create'. You will get a wizard to create Context Node -> Click Continue. Provide details as:







Click 'Continue'.'Continue'.'Continue'.'Continue'. Complete.

Observe the classes created, and try to think about them, what they are..............

Now, we will write code at 'EH_ONSEARCH' for Firing Advanced query, and passing resulted data to Context node 'ResultObjectV'.

Double click on 'EH_ONSEARCH' under Event handlers. Write the code as:







Sorry for providing screen shot, I want you to write the code, and analyse it.
Save and Activate it.

Go and test the application. Are you getting data in Resultview.

No, We have fired the query.. fine.
resulted data we send to context node of.............Advsearchview, not of Resultview.

Now, the task is to pass data from AdvSearchView's Context node (ResultObjectV) to ResultView's Context node "Resultobject'.

Need to check in next chapter.

No comments:

Post a Comment