tailieunhanh - Lotus Domino Release 5.0 A Developer’s Handbook phần 9
Điều cuối cùng phải làm là đầu ra các thông tin vào các trình duyệt Web. Điều này được thực hiện bằng cách sử dụng lệnh In LotusScript và sự kết hợp của các thẻ HTML và biến chúng tôi được giao. Nếu bạn nhìn lại vào mã đại lý EmployeeLookup chúng tôi tạo ra trước đó, bạn sẽ thấy một dòng giống như thế này | Calculate how long the string is URLLength Len URLString Find the position of the in the string ParamPosition Instr URLString 1 Now we can extract the employee number from the string WebParam Mid URLString ParamPosition URLLength-ParamPostion If we need to we can send the parameter to the Web browser to check it. Print WebParam Now that we know the employee number we can use the LS DO to query the EMPLOYEE table in the SAMPLE database and extract all the information we require. This is done with the following SQL query SELECT FROM EMPLOYEE WHERE EMPNO WebParam . The final thing to do is output the information onto the Web browser. This is done using the LotusScript Print command and a combination of HTML tags and the variables we assigned. Digging Deeper If you look back at the EmployeeLookup agent code we created earlier you will see a line that looks like this Print Work Department a href . DeptLookup OpenAgent workdept workdept a BR This line of code creates an HTML link to another agent in the database called DeptLookup. If you look carefully at the figure below you will see how this looks. Work Department A00 Phone Number 3978 Hire Date 1 1 65 Job PKES Education Level 18 Notice that the line beginning with Work Department displays its value as a URL. Clicking this hotspot will run the agent DeptLookup on the Domino server with a parameter of A01. The code for this agent is very similar to the EmployeeLookup agent but this time it retrieves a list of all employees that work in the same department. The code for the DeptLookup Agent is shown below Sub Initialize Set session New NotesSession Set conn New ODBCConnection Set query New ODBCQuery Chapter 14 Using Other Database Connectivity Tools 551 Set data New ODBCResultSet Set conn Set query Set doc Set db True USERNAME DB2Admin PASSWORD password URLString 0 URLLength Len URLString ParamPosition Instr .
đang nạp các trang xem trước