Lotus Domino Release 5.0 A Developer’s Handbook phần 9 pps

71 365 0
Lotus Domino Release 5.0 A Developer’s Handbook phần 9 pps

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

' 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. 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 query.connection = conn Set data.query = query Set doc = session.DocumentContext Set db = Session.CurrentDatabase conn.SilentMode = True USERNAME$ = "DB2Admin" PASSWORD$ = "password" URLString = doc.Query_String(0) URLLength = Len(URLString) ParamPosition = Instr(URLString, "&") + 1 WebParam = Mid(URLString, ParamPosition, URLLength-ParamPosition) 'Print WebParam If Not conn.ConnectTo("SAMPLE", USERNAME$, PASSWORD$) Then Print "Not OK, Could not Connect!" error% = Conn.GetError message$ = Conn.GetErrorMessage(error%) extendedMessage$ = Conn.GetExtendedErrorMessage(error%) Print message$ & "<br>" Print "Error Code: " & Str$(error%) Print "Extended Error: " & ExtendedMessage$ & "<HR>" Exit Sub End If query.SQL = "SELECT * FROM EMPLOYEE WHERE WORKDEPT='" & WebParam & "'" If Not data.Execute Then Print data.GetExtendedErrorMessage,, data.GetErrorMessage Exit Sub End If Print "<HEAD><BODY>" Print "<H3>These are other employees that work in department " & WebParam & "</H3>" Print "<TABLE border="1">" Print "<TR>" Print "<TD>FirstName</TD>" Print "<TD>Init</TD>" Print "<TD>LastName</TD>" Print "<TD>Department</TD>" Print "<TD>Phone</TD>" Print "<TD>HireDate</TD>" Print "<TD>Job </TD>" Print "<TD>EdLevel</TD>" Print "<TR>" 552 Lotus Domino Release 5.0: A Developer’s Handbook Do data.NextRow EmpNo = data.GetValue("EMPNO", Empno) FirstName = data.GetValue("FIRSTNME", firstName) LastName = data.GetValue("LASTNAME", lastName) MidInit = data.GetValue("MIDINIT", MidInit) WorkDept = data.GetValue("WORKDEPT", WorkDept) PHONENO = data.GetValue("PHONENO", PhoneNo) HIREDATE = data.GetValue("HIREDATE", HireDate) JOB = data.GetValue("JOB", Job) EDLEVEL = data.GetValue("EDLEVEL", EdLevel) SEX = data.GetValue("SEX", Sex) BIRTHDATE = data.GetValue("BIRTHDATE", BirthDate) SALARY = data.GetValue("SALARY", Salary) BONUS = data.GetValue("BONUS", Bonus) COMM = data.GetValue("COMM", Comm) Print "<TR>" Print "<TD><a href=./EmployeeLookup?OpenAgent&" & EmpNo & ">" & firstName & "</a>" & "</TR>" Print "<TD>" & MidInit & "</TR>" Print "<TD>" & lastName & "</TR>" Print "<TD>" & workdept & "</TR>" Print "<TD>" & PhoneNo & "</TR>" Print "<TD>" & HireDate & "</TR>" Print "<TD>" & Job & "</TR>" Print "<TD>" & EdLevel & "</TR>" Print "</TR>" Print "<BR>" Loop Until data.IsEndOfData Print "</TABLE>" Print "</BODY></HEAD>" data.Close(DB_CLOSE) conn.Disconnect End Sub Notice that this agent formats the output using an HTML table. This is particularly good for displaying tabular information back to a Web browser and is fairly simple once you understand the HTML tags. Ends the table</TABLE> Ends the current row</TR> Ends the current column</TD> Defines the start of a new column<TD> Defines the start of a new row<TR> Defines the start of a new table<TABLE> Description H TML Tag Chapter 14: Using Other Database Connectivity Tools 553 Below is a figure of how the form looks when displayed in a Web browser: Again we have added a small piece of code in this agent that allows the user to retrieve more information by clicking a name in the table and running the EmployeeLookup agent again. This is achieved with the following line of code: Print "<TD><a href=./EmployeeLookup?OpenAgent&" & EmpNo & ">" & firstName & "</a>" & "</TR>" With a little imagination it is possible to give your employees or customers real-time access to your company’s relational databases and the capabilities to drill down through the information from a Web browser. Running Multiple Instances of an Agent When Domino is being used as a Web server to access and display data from external sources via the LS:DO and LotusScript agents, you need to add a line into the NOTES.INI file on the Domino server. DominoAsynchonizeAgents=1 This enables an agent to be run by more than one person at the same time. By default the Domino server only runs one copy of an agent at a time and queues other requests. 554 Lotus Domino Release 5.0: A Developer’s Handbook Using @DB Functions to Access Other Databases Through ODBC @DBCommand, @DBLookup and @DBColumn are Notes functions that enable you to access RDBMSs which use the underlying ODBC interface. The @DB formulas are read-only. The basic purpose of these functions is to create value lists for keyword fields. @DBLookup and @DBColumn can be used to query a relational database; @DBCommand is only used for executing stored procedures. @DBCommand does not return result sets. If you need a more customized and more complex query, LS:DO is a better option. When to Use Lotus Notes provides fast and easy-to-use read access to ODBC-compliant DBMSs via @DB functions. Notes @DB functions give developers the power of three frequently-used query tasks: • Generating Keyword Lists The @DBColumn function in the Notes formula language generates Notes keyword lists from internal, as well as external, data sources. The same function supports keyword value lookups in tables stored in a DBMS through ODBC. For example, a Notes @DBColumn field formula can present a keyword list of customer names stored in a DBMS table when composing a document in a Notes customer contact tracking database. • Performing Lookup Operations The @DBLookup function looks up a value in one field based on the value of a related field. For example, it will look up a customer phone number in a DBMS when given a customer name in Notes. Like @DBColumn, @DBLookup works both with other Notes databases and with external data sources through ODBC. The @DBColumn and @DBLookup functions can be used in other Notes formula contexts as well, such as input validation or translation formulas. • Launching External DBMS Stored Procedures Database procedures and insert statements can be triggered with the @DBCommand function. Note Some of these functions inherently involve a delay before they complete; so in order to set user expectations, it is sometimes a good idea to code the functions behind a button so that the user expects some delay before the function is completed. Chapter 14: Using Other Database Connectivity Tools 555 How to Use @DB Functions The @DB functions are summarized in the following table: (any SQL statement)Triggers stored procedures in the external database. @DBCommand SELECT column FROM table WHERE condition Performs a lookup. Returns a specified column value in the row that matches the specified condition. @DBLookup SELECT DISTINCT column_name FROM table_name Generates a keyword list. Returns a specified column for all rows in the specified table. @DBColumn Equivalent SQLDescriptions F unctions @DBColumn The @DBColumn syntax is: @DBColumn( "ODBC": Cache ; DataSource ; UserID1 : UserID2 ; Password1 : Password2 ; TableName ; ColumnName : NullHandling ; Distinct : Sort ) Parameters: X“Ascending” “Descending” Sort DirectionSort) X“Distinct”Remove duplicate values Distinct: X“Fail” “Discard” (Default) “ReplacementValue ” Null HandlingNULLHandling, Column NameColumnName: Table NameTableName, XPasswordsPassword1:Passwor d2, XUser IDsUserID1:UserID2, Database resource name DataSource, X“Cache” (Default) “NoCache” Inquiry CacheCache, OptionalChoiceDescription@DBColumn(“ODBC ”: 556 Lotus Domino Release 5.0: A Developer’s Handbook @DBLookup The @DBLookup syntax is: @DBLookup( "ODBC": Cache ; DataSource ; UserID1 : UserID2 ; Password1 : Password2 ; TableName ; ColumnName : NullHandling ; KeyColumn ; Key ; Distinct : Sort ) Parameters: X“Ascending” “Descending” Sort DirectionSort) X“Distinct”Remove duplicate values Distinct: Search String in KeyColumn Key, Column Name to be looked into KeyColumn, X“Fail” “Discard” (Default) “ReplacementValue” Null HandlingNULLHandling, Column NameColumnName: Table NameTableName, XPasswordsPassword1:Password2, XUser IDsUserID1:UserID2, Database resource name DataSource, X“Cache” (Default) “NoCache” Inquiry CacheCache, OptionalChoiceDescription@DBLookup(“ODBC”: @DBCommand The @DBCommand syntax is: @DBCommand( "ODBC": Cache ; DataSource ; UserID1 : UserID2 ; Password1 : Password2 ; SQL ; NullHandling ) Chapter 14: Using Other Database Connectivity Tools 557 Parameters: X“Fail” “Discard” (Default) “ReplacementValue” Null HandlingNULLHandling ) SQL StatementSQL XPasswordsPassword1:Password2, XUser IDsUserID1:UserID2, Database resource name DataSource, X“Cache” (Default) “NoCache” Inquiry CacheCache, OptionalChoiceDescription@DBCommand(“ODBC”: Summary This chapter covered NotesSQL, the Domino JDBC driver and LotusScript Data Object (LS:DO). We discussed the circumstances where each method should be applied and also gave some examples of their use. 558 Lotus Domino Release 5.0: A Developer’s Handbook Domino Global WorkBench is a set of software tools that helps you manage the localization (translation) of the design elements in Domino databases, especially Web site databases. It also includes synchronization features that help you manage the content of localized databases across languages. Also, when the design of a database changes, you can use the update features of Domino Global WorkBench to transmit the changes easily through to the localized versions. Domino Global WorkBench is part of Domino Designer but has its own installation program. Who Benefits from Domino Global WorkBench Typical users of applications prepared by Domino Global WorkBench are companies that want to reach customers in several countries through the World Wide Web and companies with offices in several countries that need localized intranet applications. What is Localization? “Localizing” a database (.NSF file) or database template (.NTF file) means creating a version of it in another language. In general, localization involves: 1. Analyzing and sometimes modifying the design to make the remaining localization tasks simpler and identifying the text that is not to be translated (for reasons of functionality). 2. Translating the text in the design elements. All text seen by users is translated, as well as some text that is not seen by users. 3. Modifying the layout. Translations are often significantly longer than the original text, and this means that certain parts of the design, for example tables and navigators, will usually have to be adjusted. Which Processes Support Domino Global WorkBench Domino Global WorkBench is used by the application developer during the development and maintenance process and by the content provider during the ongoing content updating process across languages. Chapter 15 Domino Global WorkBench 559 The following figure shows an example of a localization process during development and maintenance and the roles involved in it: Develo p ers Localization Develo p er Translators Localization Validators DEVELOP EXTRACT TRANSLATABLE MATERIAL PREPARE GLOSSARIES TRANSLATE BUILD LANGUAGE VERSIONS VERIFY  The process in the figure is just a simple example. Domino Global WorkBench does not require a specific process to be followed, but offers full flexibility in integrating with the process you are using for your development and content creation. Note The people shown in the figure represent different roles. You don’t need a huge development organization to use Domino Global WorkBench. One person may cover several roles; for example, a developer may also be the localization developer as well as the translator. 560 Lotus Domino Release 5.0: A Developer’s Handbook [...]... have information and error messages written to the report database The language database is the output from Domino Global WorkBench The design elements are taken from the tagged database and the tags are replaced with the translated terms in the chosen language from the glossary The language database can store multiple language versions in the same database or one database can be created for each language... documents to be translated in existing databases You can mark each form in an existing language database in one of three ways: • Translatable In the language database(s), any document created from this form will be copied automatically to other languages and marked for translation • Global In the language database(s), any document created from this form will be copied automatically to other languages but will... Pseudo Language 1 In the WorkBench select the tagged database and then select Click Here To Specify Language Databases The New Language Database dialog box appears: 2 Select Pseudo in the Available Languages list box Drag it over to the Selected Language(s) list box and drop it under Language Database 1 Click OK 3 Press the button in the WorkBench that says Build Language Database 4 A Language Database... application databases) • Glossary database(s) for the chosen source database • A tagged database version of the chosen source database • Language database(s) for the chosen source database You can optionally also show a log window where messages are written during processing The options available in the WorkBench depend on which kind of databases you select For example, if you select a tagged database, Domino. .. manually, working in the Notes client In earlier versions of the translation tools, this tool was called The Populator You can use the Tagger to manually tag terms that were missed during the full database tagging process 564 Lotus Domino Release 5.0: A Developer’s Handbook Caution The Tagger allows you to change text in the tagged database Be aware that if you do this, your tagged database (and the language... translation work, and the synchronizer technique 562 Lotus Domino Release 5.0: A Developer’s Handbook Domino Global WorkBench Databases You will encounter several types of databases in Domino Global WorkBench They are: Source Database A source database is the completed application (or part of it) in the original language (the reference language) If the developer updates the application, the source database... glossary A glossary can also contain already translated terms Domino Global WorkBench can identify these terms in the source database and tag them with the tags for the existing terms without creating new duplicate terms Glossaries can be assigned to a database or a collection of databases You can also assign more than one glossary per database When working with Domino Global WorkBench, the user can... combining several action buttons into one cascaded action button If you have found any sizing problems that require changes to the source database, you must update or rebuild your tagged database and the language database and then check again When you can validate that all translatable terms in the application have been tagged and that no sizing problems seem to exist, the localization developer can continue... source database must be updated by the new version Tagged Database The tagged database is a copy of the source database where all translatable text and pictures have been exported and replaced with unique tags This database is an interim product It allows you to generate multiple language databases The glossary stores the terms that have been exported from the source database, together with a reference... have been created during the latest tagging and terms that have been marked Allow Translation The Pseudo terms that have already been reversed are marked as translated and will not be touched by this new Pseudo translation As you have made changes to the translations in the glossary you must rebuild the language database (rather than just update it) In the WorkBench, select the Pseudo language database . panes for: • Source databases (original application databases) • Glossary database(s) for the chosen source database • A tagged database version of the chosen source database • Language database(s). "<TR>" 55 2 Lotus Domino Release 5. 0: A Developer’s Handbook Do data.NextRow EmpNo = data.GetValue("EMPNO", Empno) FirstName = data.GetValue("FIRSTNME", firstName) LastName = data.GetValue("LASTNAME",. terms that were missed during the full database tagging process. 56 4 Lotus Domino Release 5. 0: A Developer’s Handbook Caution The Tagger allows you to change text in the tagged database. Be aware

Ngày đăng: 08/08/2014, 18:22

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan