back to the demo ActiveSearch for Web Views
This tool is useful for nearly any Domino web application. It is used to provide a "Search Function" for web views. Domino does not provide any facility to navigate to a specific position within a view. But very often the user wants to navigate to a specific view entry.
In "normal" web applications the user has to step through the view pages until the wanted position is reached. Or a full text search is required. Or the view has to be categorized in a useful manner.
All of the given navigation functions have more or less disadvantages. Best would be a quick search function as for the Notes client. The ActiveSearch for Web Views gives you the tool to let the user search within web views nearly the same way as for the Notes client.
Advantages of ActiveSearch for Web Views
- Very fast navigation within the view
- Very easy and comfortable to use. The search field is focused by default. The user just types the term to search for and presses the "Enter" button or clicks the "Search" button.
- If you have read access within the documents: make your web views "flat" without categories. Thus you won't have problems with "invisible" documents like in categorized views. And ActiveSearch will locate only documents the user is able to read.
- If you have set the "lines per view page" parameter in your server document to a high value: decrease the number of lines per view page (default is 30) and save network traffic. You don't need large view pages because ActiveSearch enables you to navigate directly to the view page you are looking for.
What you need to know about the ActiveSearch for Web Views:
You only need the following design elements within your database:
- Agent "(ViewGoto)"
- LotusScript library "WEBTOOLS"
Within the view page (e.g. a view template form) some JavaScript and HTML code is added and everything is ready for your ActiveSearch. You need to copy the JavaScript functions replaceSubString() and callAgent() into your view page
JavaScript functions
<Script Language="JavaScript"><!--
function replaceSubString(s, ts1, ts2){
// replace in s ts1 by ts2
var newValue = ""
var ts1len = ts1.length
var i = 0
while (i < s.length){
if (s.substring(i, i+ts1len) != ts1){
newValue = newValue + s.substring(i, i+1)
i++
}
else{
newValue = newValue + ts2
i += ts1len
}
}
return newValue
}
function callAgent(){
//call the navigation agent
form =window.document.ViewGoTo
Z = replaceSubString(form.Goto.value," ","+")
location = "/home/activeSearch-offen.nsf/(ViewGoto)?OpenAgent&GoTo="+Z+"&&"
return false
}
//-->
</Script>
Anywhere in your form the search field and button is needed. There are two examples. One for databases where the option "Generate JavaScript when generating pages" is not set and the other if it is set. The difference is only a matter of the form tag
Also the two fields Query_String and Path_Info must be in the form. If you want to focus the search field by default please enter the following code to the "HTML Attributes" event of your view form:
Attention: The Agent needs to have the flag "Run agent as web user" set. Thus the user may find only documents he is able to read (if there are read restrictions)
"onLoad=\"document.ViewGoTo.Goto.focus()\""
You may have a look at the form $$ViewTemplateDefault in current database. This form may serve you as a running example.
Restrictions:
- The function runs only on JavaScript enabled Browsers
- The view where to search for must be sorted by a text. Numbers and date/time values are not yet supported by this demo. The view may be categorized or not. The sort order may be ascending or descending.
- The search can only be performed within the first sorted column of the view
- The demo is running on Windows32 platforms only
- The demo contains an additional JavaScript alert when performing a search
|