« Learning XPages Part 52 : Getting And Displaying The Search Results | Main| Learning XPages Part 54 : The End... »

Learning XPages Part 53 : Building The Search Results XPage

Tags : Lotus Domino XPages
Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 

Our search bar is complete but searching for something right now will result in an error because the page that we are trying to open does not exist in the application. In this part I'm going to build the search results XPage and show you how to display the results.

Lets start by copying and pasting one of our existing XPages and renaming it to 'Search'. Because I want to search for people I have decided to copy the 'Location' XPage. Once renamed I then went to the custom control and duplicated the content_Location custom control and renamed it to content_Search. I then returned to the 'Search' XPage and in the source view I updated it to use the 'content_Search' custom control instead of the content_Location one. By breaking your application layout into these smaller custom controls you can quickly add entire new parts to the application just like we have done here.

Now lets open the content_Search custom control. There are a few things we need to do to tidy this custom control up before we make it display the search results. The first thing we need to do is remove the two panels at the top of the screen that display the location information and the action bar. You should just have your pager and table ( with repeat inside ) left on the screen.

A picture named M2

In the data tab for the custom control you can remove the datasource for the locationDoc so you are just left with the datasource for the peopleView.

A picture named M3

You can also remove the server side script library from the resources section and in the all properties section you can remove the beforePagesLoads script.

A picture named M4

Our page is now cleaned of all the bits we no longer need, all that's left to do it tell the data source that we want to do a search.

Staying in the all properties view for the custom control open out the data section till you find your data source. We want to make sure that the search is done across all the documents in the view so we will need to remove the categoryFilter.

A picture named M5

Next move down to the search property. In here we will compute the value so click on the diamond and enter in the following code

A picture named M6

A picture named M7

Now save the custom control and try doing a search in your application. Here's the result of a search for the name Smith.

A picture named M8

You might want to adjust the table to show the location name for the person but in terms of searching that's it. Simple.