- Java code
Sub Initialize() On error GoTo errorprocess Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim view1 As NotesView Dim view2 As NotesView Dim doc As NotesDocument Dim doc1 As NotesDocument Dim doc2 As NotesDocument Set session=New notessession Set db=session.Currentdatabase Set view2=db.Getview("SortsManagementList") Set doc2=view2.Getfirstdocument() Set view=db.Getview("SortsList_Top") Set view1=db.Getview("SortsList") Set doc=view.Getfirstdocument() Set doc1=view1.Getfirstdocument() Print "<html>" Print "<head>" Print "</head>" Print "<body>" Print " <ul> "Do While Not(doc Is Nothing ) Print " <li>"+doc.SortName(0)+"</li>" While Not(doc1 Is Nothing ) If(doc.SortName(0)=doc1.ParentName(0)) Then Print "<ul><li>"+doc1.SortName(0)+"</li></ul>" End If Set doc1=view1.Getnextdocument(doc1) Wend Set doc=view.Getnextdocument(doc) Loop Print"</ul>" Print"</body>" Print"</html>"Exitentry: Exit Sub errorprocess:Print error + CStr(erl)End Sub
错误:The Document is not in View SortsList_Top32
也就是说我的父循环只读出第一条,然后循环子循环找出对应的数据,到第二条就找不到了!但是我想了半天,我这个写法没错误。跪求解析!
我这是要产生树状菜单(用列表显示),如果有人会用递归做无限菜单求之不得!可以贴代码!
------解决方案--------------------
逻辑有问题,在第二个循环的开始应该重新初始话那个doc1,应为当外循环第二次运行到这里的时候,它已经被设置为Nothing了,永远不能第二次进入第二个循环。
- Java code
Sub Initialize() On error GoTo errorprocess Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim view1 As NotesView Dim view2 As NotesView Dim doc As NotesDocument Dim doc1 As NotesDocument Dim doc2 As NotesDocument Set session=New notessession Set db=session.Currentdatabase Set view2=db.Getview("SortsManagementList") Set doc2=view2.Getfirstdocument() Set view=db.Getview("SortsList_Top") Set view1=db.Getview("SortsList") Set doc=view.Getfirstdocument() Set doc1=view1.Getfirstdocument() Print "<html>" Print "<head>" Print "</head>" Print "<body>" Print " <ul> "Do While Not(doc Is Nothing ) Print " <li>"+doc.SortName(0)+"</li>"[color=#FF0000]Set doc1=view1.Getfirstdocument()[/color] While Not(doc1 Is Nothing ) If(doc.SortName(0)=doc1.ParentName(0)) Then Print "<ul><li>"+doc1.SortName(0)+"</li></ul>" End If Set doc1=view1.Getnextdocument(doc1) Wend Set doc=view.Getnextdocument(doc) Loop Print"</ul>" Print"</body>" Print"</html>"Exitentry: Exit Sub errorprocess:Print error + CStr(erl)End Sub