Domino下实现仿Google搜索提示效果
2009-10-16 22:38
706 查看
[align=left] 随着Ajax的运用越来越广泛,越来越多的用户体验被提升,在Domino中应用Ajax实现Google搜索提示效果,在用户的使用过程中也是一种很实用的体验,下面将详细介绍下实现的思路和方法,仅供参考,以下代码在Domino6.5和ie 6中正常运行通过,效果如下图。
Code
Sub Initialize
Dim Session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim cgi As NotesDocument
Dim docs As NotesDocumentCollection
Set cgi = Session.DocumentContext
Set db=Session.CurrentDatabase
Dim key As String
key= GetParameter("keyword",cgi.GetItemValue("Query_String_Decoded")(0)) 'GetParameter函数的作用是获取url中&keyword=的值
Set view = db.GetView("视图名")
Dim formalue As String
formalue={Form = "文档的表单名" & @contains(name;"}+Trim(key)+{")} 'name为查询文档的一个域
Set docs=db.Search(formalue,Nothing,0)
Print "Content-type: text/xml" '输出xml文件的表头
Print |<?xml version="1.0" encoding="GB2312" ?> |
Print "<result>"
If docs.Count<>0 Then
Dim words() As String
Dim i As Integer
i=1
Set doc=docs.GetFirstDocument()
While Not doc Is Nothing
words(i)=doc.name(0) 'name为查询文档的一个域,此处可根据具体情况而定
i=i+1
Set doc=docs.GetNextDocument(doc)
Wend
Dim x As Variant
x=Arrayunique(words) '去掉数组中的重复值
Dim cols As NotesDocumentCollection
Dim malue As String
Forall one In x
If one<> "" Then
malue={Form = "文档的表单名" & @contains(name;"}+Trim(one)+{")}
Set cols=db.Search(malue,Nothing,0)
Print "<first>" 'print出xml文件的格式,格式可根据自己的喜好更改
Print one
Print "</first>"
Print "<second>"
Print Cstr(cols.Count)
Print "</second>"
End If
End Forall
Else
Print "<first>"
Print key
Print "</first>"
Print "<second>"
Print "0"
Print "</second>"
End If
Print "</result>"
End Sub
[/align]
上面的代码只是为了粗略的实现Google搜索提示的效果,在真正的使用这种效果的时候代理查询要更复杂,前台展示的效果要更细腻,由于代码写的比较仓促,以致根本来不及估计编码规范,看得懂就好。
Code
Sub Initialize
Dim Session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim cgi As NotesDocument
Dim docs As NotesDocumentCollection
Set cgi = Session.DocumentContext
Set db=Session.CurrentDatabase
Dim key As String
key= GetParameter("keyword",cgi.GetItemValue("Query_String_Decoded")(0)) 'GetParameter函数的作用是获取url中&keyword=的值
Set view = db.GetView("视图名")
Dim formalue As String
formalue={Form = "文档的表单名" & @contains(name;"}+Trim(key)+{")} 'name为查询文档的一个域
Set docs=db.Search(formalue,Nothing,0)
Print "Content-type: text/xml" '输出xml文件的表头
Print |<?xml version="1.0" encoding="GB2312" ?> |
Print "<result>"
If docs.Count<>0 Then
Dim words() As String
Dim i As Integer
i=1
Set doc=docs.GetFirstDocument()
While Not doc Is Nothing
words(i)=doc.name(0) 'name为查询文档的一个域,此处可根据具体情况而定
i=i+1
Set doc=docs.GetNextDocument(doc)
Wend
Dim x As Variant
x=Arrayunique(words) '去掉数组中的重复值
Dim cols As NotesDocumentCollection
Dim malue As String
Forall one In x
If one<> "" Then
malue={Form = "文档的表单名" & @contains(name;"}+Trim(one)+{")}
Set cols=db.Search(malue,Nothing,0)
Print "<first>" 'print出xml文件的格式,格式可根据自己的喜好更改
Print one
Print "</first>"
Print "<second>"
Print Cstr(cols.Count)
Print "</second>"
End If
End Forall
Else
Print "<first>"
Print key
Print "</first>"
Print "<second>"
Print "0"
Print "</second>"
End If
Print "</result>"
End Sub
[/align]
上面的代码只是为了粗略的实现Google搜索提示的效果,在真正的使用这种效果的时候代理查询要更复杂,前台展示的效果要更细腻,由于代码写的比较仓促,以致根本来不及估计编码规范,看得懂就好。
相关文章推荐
- Domino下实现仿Google搜索提示效果
- Domino下实现仿Google搜索提示效果
- 实现类似google搜索效果,文本框输入智能提示,没有用ajax控件和第三方控件,完全手写代码
- 实现类似google搜索效果,文本框输入智能提示,(经过改进 支持多个文本框的效果)
- 用Jquery实现模仿Google 搜索提示功能
- AJAX实现类似Google搜索提示的基础配置
- js实现搜索框智能提示上下移动效果
- .NET中使用js实现百度搜索下拉提示效果[不是局部刷新,呜呜。。]
- WinForm"搜索提示效果(不错的)实现" 之 配餐系统的开发
- WinForm"搜索提示效果(不错的)实现" 之 配餐系统的开发
- jquery+ajaxpro实现google输入提示效果(含拼音匹配)
- 在Winfrom下实现类似百度、Google搜索自能提示功能
- winform实现类似google的搜索提示Suggest Search
- asp.net+js实现的ajax sugguest搜索提示效果
- jquery 关键字“拖曳搜索”之“拖曳”以及 图片“提示自适应放大”效果 的实现
- mootools实现搜索提示文本框 (仿GOOGLE)
- 在Winfrom下实现类似百度、Google搜索自能提示功能
- WinForm"搜索提示效果(不错的)实现" 之 配餐系统的开发
- jQuery实现搜索框智能提示效果
- ajax Suggest类似google的搜索提示效果