`
iatneh
  • 浏览: 4252 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

获得lotus 嵌入视图 选中的文档

 
阅读更多

原文链接:
http://www.nsftools.com/tips/SelectedDocsList.lss


以下代码自己备份一下


'** Notes C-API functions used by the UnreadDocList class (these are Windows-specific
'** calls -- please adjust as necessary for other operating system platforms)
Declare Function OSPathNetConstruct Lib "nnotes.dll" (Byval portName As Integer, _
Byval serverName As String, Byval fileName As String, Byval pathName As String) As Integer

Declare Function NSFDbOpen Lib "nnotes.dll" (Byval dbName As String, rethDb As Long) As Integer
Declare Function NSFDbClose Lib "nnotes.dll" (Byval hDb As Long) As Integer

Declare Function NIFOpenCollection Lib "nnotes.dll" (Byval hDB As Long, _
Byval hDB As Long, Byval ViewNoteID As Long, Byval openFlags As Integer, _
Byval hUnreadList As Long, hCollection As Long, Byval hNullVal As Long, _
hViewUnid As Long, hCollapsedList As Long, hSelectedList As Long ) As Integer

Declare Function NIFCloseCollection Lib "nnotes.dll" (Byval hCollection As Long) As Integer

Declare Function IDEntries Lib "nnotes" ( Byval hTable As Long ) As Long
Declare Function IDScan Lib "nnotes" ( Byval hTable As Long, Byval tFirstBool As Integer, _
retID As Long) As Integer

Declare Function OSMemFree Lib "nnotes" (Byval handle As Long) As Integer

'** Error code masks
Const ERR_MASK = &H3fff
Const PKG_MASK = &H3f00
Const ERRNUM_MASK = &H00ff

Declare Function OSLoadString Lib "nnotes.dll" (Byval hModule As Long, Byval stringCode As Integer, _
Byval retBuffer As String, Byval bufferLength As Integer) As Integer


Class SelectedDocsList

%REM
The SelectedDocsList class provides a way to programmatically access
the list of selected docs in a view that's currently open in the Notes client
(open in a tab, a frame, or as an embedded view), without relying on an
agent to be running against "Selected docs" in a view.

Because we're calling the C-API, you'll also need to declare several API
functions in the Declarations section of the agent or script library that
holds this class. If you got this class without the related API declarations,
please see the original version of this code at http://www.nsftools.com

Here's an example of getting the selected docs in a view:

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument

Set db = session.CurrentDatabase
Set view = db.GetView("All docs")

Dim selected As New SelectedDocsList(view)
Print "Count = " & selected.Count

Set doc = selected.GetFirstDocument
Do Until (doc Is Nothing)
Print doc.NoteID & " was created on " & doc.Created
Set doc = selected.GetNextDocument(doc)
Loop


A few things to note about this class:

1. This will ONLY work when running on a local Notes client, while the
client is open. If you try to run it on your server, you may crash it.

2. The docs are NOT returned in the same order they are seen in the view.
They seem to be in order of creation date, starting from the earliest (although
this is just what I've seen in preliminary testing, and might not be true all the time).

3. If the view that you're pointing to is not currently open in the client anywhere,
this class should just return a GetCount value of 0 (not an error or a crash).

4. If you're using this in an agent, you do NOT need to have the agent set
to run against "Selected Docs". However, it's very possible that the agent
has to be run by the user (as opposed to a background agent) -- I haven't
done any testing on background/scheduled agents, but this class is really
meant to be run in the front-end.

5. One way that I used this class was to get the docs that were selected
in a view that was embedded on a Form. Doing this, I could allow actions
and buttons on the Form to access the selected docs in the embedded view
by simply passing a proper handle to the view that was embedded. In other
words, if the embedded view is called "SpecialDocs", you simply create
an instance of the class using db.GetView("SpecialDocs") in the constructor.
You can do this when the form is opened and keep it in memory as a global
object if you want. Just remember to call the RefreshList method before you
try to get the selected docs at any given time, to make sure you have the
current list. However....

6. This does NOT return the proper document list for embedded views that
have "Show Single Category" set.

You can use this code in any way you want, as long as you don't hold me
liable for anything, and you don't pretend you wrote it yourself.

version 1.0
December 29, 2005
Julian Robichaux ( http://www.nsftools.com )
%END REM


Private idArray() As String
Private thisDb As NotesDatabase
Private thisView As NotesView
Private lastError As String
Private lastDoc As NotesDocument
Private lastIndex As Integer


Public Sub New (view As NotesView)
'** We'll allow the user to pass a view when an instance of
'** this class is created, to make things a little easier. If you
'** don't have a valid view handle when you're instantiating
'** this class, just use Nothing as the view parameter.
Call SetView(view)

'** No lazy referencing here. We'll go ahead and try to grab
'** the list of selected docs right away
Call RefreshList()
End Sub


Public Sub SetView (view As NotesView)
'** This can be used to change the view that we're looking at.
Set thisView = view
If (view Is Nothing) Then
Set thisDb = Nothing
Else
Set thisDb = view.Parent
End If

'** reset the internal variables
Call ResetPrivates

'** Notice that RefreshList is NOT called automatically when the
'** view reference is changed. If you want a new list of selected
'** docs, remember to call RefreshList yourself. This is just in case
'** you have code that switches views a lot (like a form with an
'** embedded view or a frameset)
End Sub


Private Sub ResetPrivates ()
'** reset all the internal references and counters
Redim idArray(0) As String
lastError = ""
Set lastDoc = Nothing
lastIndex = 0
End Sub


Public Function GetIDArray () As Variant
'** return the internal list of NoteIDs we're storing as an array of Strings
GetIDArray = idArray
End Function


Public Function Parent () As NotesView
'** return the view that we're currently referencing
Set Parent = thisView
End Function


Public Function Count () As Long
'** How many NoteIDs do we have in our internal array?
Count = Ubound(idArray) - Lbound(idArray) + 1

'** if there's only one item and it's blank, we should consider our
'** array to be empty and return a count of 0
If (Count = 1) And (idArray(Lbound(idArray)) = "") Then
Count = 0
End If
End Function


Public Function GetNthDocument (n As Integer) As NotesDocument
'** return a handle to the Nth document in our array, if possible
Set lastDoc = Nothing

'** exit early for invalid conditions
If (thisDb Is Nothing) Then
'** oops, no database handle
Exit Function
Elseif (n > Ubound(idArray)) Or (n < Lbound(idArray)) Then
'** array out of bounds
Exit Function
Elseif (idArray(n) = "") Then
'** empty value
Exit Function
End If

Set GetNthDocument = thisDb.GetDocumentByID(idArray(n))

'** we store references to the lastDoc and lastIndex for efficiency
'** in the GetNextDocument method
Set lastDoc = GetNthDocument
lastIndex = n
End Function


Public Function GetFirstDocument () As NotesDocument
'** returns a handle to the first doc in our collection
Set GetFirstDocument = GetNthDocument(Lbound(idArray))
End Function


Public Function GetLastDocument () As NotesDocument
'** returns a handle to the last doc in our collection
Set GetLastDocument = GetNthDocument(Ubound(idArray))
End Function


Public Function GetNextDocument (doc As NotesDocument) As NotesDocument
'** returns a handle to the next selected doc after the one that
'** the user passes us, just like GetNextDocument in NotesView
'** or NotesDocumentCollection (remember that the docs on
'** our list aren't in the same order as the View itself, though)
Dim i As Integer

'** for efficiency, see if the doc the user passed as a parameter is
'** the same as the last doc we gave them (which is almost always
'** the case, because this will normally be called in a Do
分享到:
评论

相关推荐

    LOTUS详细技术文档

    Lotus Script支持多种数据类型、控制结构、函数库,以及与Notes对象(如文档、视图、表单)的交互。 2. **Lotus Notes/Domino架构**: Lotus Notes客户端是一个用户界面,用于访问和编辑信息,而Domino服务器负责...

    lotus打开指定的文档

    2. **通过大纲在帧结构中打开文档**: 大纲视图是Lotus Notes中组织和浏览信息的一种方式,它呈现为树形结构,允许用户通过层级节点导航。在帧结构中,不同的视图和文档可以在同一窗口的不同部分(帧)中并排显示。要...

    Lotus 开发C++ API 帮助文档

    Lotus 开发C++ API 帮助文档是针对使用Lotus软件进行C++编程的开发者设计的一份详尽参考资料。Lotus,特别是与IBM的Lotus Domino相关,是一款广泛用于企业级协同工作和信息管理的平台。C++ API(应用程序接口)提供...

    lotus notes 教程 电子书 文档 方案 计划 教材 实施 pdf

    lotus notes 教程 电子书 文档 方案 计划 教材 实施 lotus notes 教程 电子书 文档 方案 计划 教材 实施 lotus notes 教程 电子书 文档 方案 计划 教材 实施 lotus notes 教程 电子书 文档 方案 计划 教材 实施 ...

    domino xpages 开发 视图获取选择视图的文档

    3. **获取选中文档的ID**:`getComponent("viewPanel1").getSelectedIds()` 这个方法用于获取当前视图面板中用户所选择的文档的ID列表。这个列表通常是一个数组,可以通过遍历来处理每个选中的文档。 4. **处理选中...

    IBM+Lotus+Domino技术知识文档汇总(全)

    【IBM Lotus Domino技术知识文档汇总】是一份全面深入探讨IBM Lotus Domino技术的资源集合,它涵盖了从基础到高级的各种主题,旨在帮助用户更好地理解和利用这一强大的协作平台。Lotus Domino,作为IBM的一种企业级...

    Domino Web网页嵌入视图快速跳页处理技术

    通过对Lotus Domino环境下嵌入视图的翻页和快速跳页功能的研究,我们可以看到,通过动态生成URL的方法可以在保持现有系统框架的基础上,有效地提升用户体验。这种方法不仅克服了系统命令的局限性,还扩展了系统的...

    深入了解_lotus_quickr的文档管理.doc

    Lotus Quickr 是 IBM 推出的一款企业级内容协作软件,尤其在文档管理方面表现出色。文档管理是企业 IT 的核心需求,Lotus Quickr 通过其丰富的功能和特性,为用户提供了高效、便捷的文档存储、组织和共享体验。这款...

    Lotus-Notes文档数据库.pdf

    视图(View)是 Lotus Notes 中文档的主要浏览窗口,当一个视图的选择条件给定以后,通过该视图所看到的文档就是符合条件的文档,每一视图都包含符合一定条件的文档。视图除了有选择条件外,还可以按不同的特性将...

    lotus domino CS视图导出有公式列的值.docx

    视图是 Lotus Domino 数据库中的一个重要组成部分,它允许用户以各种方式组织和查看文档。 在 Lotus Domino 中,视图通常由多个列组成,这些列可以基于数据库文档中的实际字段,也可以基于计算公式。公式列可以根据...

    Domino中表单、页面、视图、文档和域之间的关系说明

    Domino 中表单、页面、视图、文档和域之间的关系说明 Domino 中的表单、页面、视图、文档和域之间的关系是一个复杂的网络系统,这些组件之间的交互和关系非常重要。下面将详细介绍每个组件的作用和关系。 表单...

    lotus notes 5 帮助文档

    将此NSF文件拷贝至Lotus\notes\data\Help 并将其更名为相应版本帮助文档名称并覆盖即可

    lotus domino 表单文档相关--文档ID

    "Lotus Domino 表单文档相关--文档ID" Lotus Domino 是一个功能强大的协作软件平台,由 IBM 公司开发,它提供了强大的文档管理功能。Lotus Domino 中的文档可以具有唯一的标识符,即文档 ID,这个 ID 是一个独特的...

    NOTES分类视图的生成

    NOTES分类视图的生成是LOTUS Notes应用开发中的一个重要环节,主要涉及到对视图(View)的定制和优化,以便更好地管理和展示数据。在NOTES中,视图是一种组织和检索数据库文档的方式,它允许用户按照特定的分类标准...

    Lotus Domino 第8章_在Web中使用视图

    视图可以嵌入到表单中,提供与当前文档相关的上下文信息。用户可以在表单中直接查看、搜索或操作相关文档,提高工作效率。 18.8.1 在表单中嵌入视图 通过设计表单时添加视图控件,可以将视图嵌入到表单中,使得用户...

    lotus domino notes安装文档

    本安装文档将详细阐述如何在操作系统环境中正确安装和配置Lotus Domino服务器以及Notes客户端。 一、Lotus Domino服务器安装 1. 系统需求:在安装Domino服务器之前,确保你的系统满足最低硬件和软件要求,包括足够...

    lotus notes 说明文档

    3. 数据库应用开发:Lotus Notes/Domino环境内置了强大的表单、视图和数据库设计工具,使得非程序员也能创建定制化的业务应用程序。这些应用可以用于库存管理、项目跟踪、客户关系管理等多个领域,极大地提高了工作...

    lotus domino附件开发--附件批量放到一个文档

    对于每个附件,我们使用 `ExtractFile` 方法来将其保存到磁盘上,然后使用 `EmbedObject` 方法将其嵌入到新的文档中。 在将所有附件处理完毕后,我们使用 `Save` 方法将新的文档保存到数据库中。整个过程中,我们...

    在Lotus中嵌入Fckeditor上传代码

    在Lotus Notes环境中,通过与Notes Form、Field和Agent的结合,FCKeditor可以用于编辑文档内容,并且能处理附件上传,极大地提升了用户界面的友好度。 在实现这个功能时,我们需要进行以下步骤: 1. **下载并引入...

Global site tag (gtag.js) - Google Analytics