Download AD203 - Advanced Techniques in LotusScript Agenda InViewEdit

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Agenda
ƒInViewEdit
–New event
AD203 - Advanced Techniques in
LotusScript
ƒRecompile
All LotusScript
–New Menu option
ƒLotusScript
Remote Debugger
–How to use it
ƒNew
Wai-ki Yip
Development Manager
Merrill Kashiwabara Development team Eng
Gary Devendorf
Product Manager
LotusScript Built-in Functions
–Split, Join, StrToken, Replace, ArrayUnique,ShellID
–Character sets
ƒLS2J
(Java Connect)
–Calling Java from LotusScript
ƒLotusScript
Web Services
–Writing a Web Service with LotusScript
InViewEdit
ƒNew
ƒUsed
View
event for Views
to enable editing Items and creating Document in the
ƒEvent
InViewEdit Event Triggers
ƒAllows
the user to edit a document through its view column
entries. Occurs as follows:
ƒ 1.
Query:
fires from the View UI
–when the user enters an editable view column entry.
ƒ
2.
ƒ
3.
Validate:
–when the user exits an editable view column entry.
Save:
–after validation of one or more view column entries in an existing
document.
ƒ
4.
New entry:
–after validation of one or more view column entries in a new document.
1
How to Use InViewEdit
Recompile All LotusScript (Menu)
ƒHelp!!!!
ƒCode
Demo
ƒRecompiles
all LotusScript in a database.
–Agents, Forms, Script Libraries, Actions, Fields, Views, etc...
ƒEach
compiled element is "Signed" with the Current Users
Signature
ƒAlternatives
–open up each element, and re-save it to force it to recompile
–use the C-API call to compile a document.
Why Recompile All?
How it Works
ƒTo
ƒCompiles
make sure that all LotusScript programs use most current
LotusScript library
ƒTo reflect code changes
–LotusScript Source.lss
–%INCLUDE
ƒTo
Re-Sign All LotusScript in Database
Script Libraries First,
Shared Fields,
ƒ
Shared Actions,
ƒ
Forms/Pages,
ƒ
Agents,
ƒ
Views/Folders
ƒCompiles in Alphabetical order EXCEPT Script Libraries.
ƒ
–MyAgent
–YourAgent
ƒScript
Libraries
–Two pass ordering
alphabetically
account for dependencies
–
–
2
Recompile Errors
ƒLotusScripts
with compile errors are displayed
–Not signed
–compile not saved
–Errors must be fixed by hand
ƒContinues
compiling through database
What does Remote Debugger give you
ƒA
means to debug LotusScript Agents deployed on a Server
Remote Debugger for LotusScript
ƒIntroduce
ƒR5
in Notes/Domino 6
IDE/designer debugging limitations
–Agent are debugged on the client only
–No way to debug non-Windows Agents
–Server Deployed Agents can not be debugged
What kind of agents you can debug
ƒAgents
that you can debug
–From the Designer Client
–scheduled
–Independent of Platform
–router agents
–Full control of the debug process
–Web agents
ƒsimilar
to the existing IDE
ƒsource level debugging
ƒsingle step
–runonserver method
–run command from the console
–step in/over
–continue
ƒexamine
ƒset/clear
and change the value of the variables
breakpoints
3
Remote Debugger - demo
Remote Debugger - Agent Configuration
ƒAgent
must be marked for remote debugging
–Property Box
Remote Debugger - Client Side Usage
Remote Debugger - Client Side Usage
(continued)
ƒCreate
ƒAn
the agent as you would normally
–make sure you have designer rights
ƒSet
the agent to run on the server
the remote debugger through the menu
ƒStart
Agent must be running to attach to it
"Agent wait at start time" to slow running agents
ƒUse
–Slows all agents on the server
ƒUse
"STOP" statement to create a break point
–Remove STOP after debugging
–displays
all servers
all agents running
on selected server
–displays
ƒOnce
attached, it appears identical to the client IDE
ƒBeware of potential performance bottleneck due to transmission
time
4
Remote Debugger - STOP statement
ƒsame
Remote Debugger - Architecture
as in client IDE
server
–no op if the debugger is not running
ƒdifference
–check if it is configured for remote debugging
–will wait for the specified amount of time
–eventually, it will time out and continue
Client 1
remote debug
add-in
Agent
LotusScript
VM
Client 2
server
Remote Debugger - Server Configuration
Remote Debugger - Server Side Execution
ƒCommunication
ƒRemote
Port
–IIOP (default to 60000, 60001-ssl)
ƒServer
Debug Add-In
–listens to the port for client communication
–creates an proxy for each agent that is running
–Enable remote debugger
Server document
–Start Wait Time (default to 0)
–this will also affects the STOP statement
–Remote add in will terminate in hrs (default to 24)
–
–each of this proxy is running as a separate thread
–debug commands goes from client to the proxy and to the agent
–Agent checks for debug command at its regular intervals
–executes the debug command and return values through the proxy to
the client.
5
Remote Debugger - Server Side Execution
(continued)
Advance Feature
ƒServer
ƒOnly
one client can be attached to an agent at one time.
–The IDE client goes to the regular Notes server to check rights
–It is has enough rights, it will ask for the source
–It will ask for the connection token to the remote debugger add-in
ƒYou
can take control of an agent someone has already attached
to
–Very useful when your client crashes
–You can still reconnect to the same agent and continue
–Able to share a debugging session with someone remotely
Remote Debugger - Common Problems
Remote Debugger - Security
ƒRemote
ƒDesigner
debug add-in is not running (or has been turned off).
is not marked "Allow remote debugging"
ƒRemotely debugged Agent is running too slow
ƒAgent
rights to the agent are required
–Agent must be marked as remotely debuggable
ƒRemote
debugger add-in will turn off by itself after some time.
Administrator will need to restart it again.
ƒCan use the secure port (x509 certificates) instead of the
regular IIOP port
6
Remote Debugger - Limitations
ƒLimitations
–Same as in Client IDE E.g. you cannot debug SUB TERMINATE
New Built-in LotusScript Functions
ƒSplit
–Debugging can change the exact conditions on the server
ƒJoin
Just stopping the agent will change the server characteristics.
–Slows down the server
ƒStrToken
–
ƒReplace
ƒArrayUnique
Split
Returns an Array of Strings that are the
substrings of the specified String
Syntax:
Split(expression as String[, delimiter as String[,
count as Integer[, compare as Integer]]]) as
Variant
MyArray=Split("this/is/my/example", "/")
MyArray(0)="this"
MyArray(1)="is"
MyArray(2)="my"
MyArray(3)="example
Join/Implode
Concatenates an Array of Strings delimited
by characters or space (" ")
Syntax:
Join(sourceArray as Variant, [delimiter as String])
as String
MyArray(0)="this"
MyArray(1)="is"
MyArray(2)="my"
MyArray(3)="example
MySting=Join(MyArray, ".")
MyString="this.is.my.example"
7
StrToken
Returns a specified "word" from a text string
Syntax:
StrToken(expression as STRING, delimiter
as STRING, wordNumber as LONG,
compMethod as INTEGER) as STRING
MyString="this.is.my.example"
MyWord=StrToken(MyString, ".", 4)
ArrayUnique (@Unique)
Removes duplicate elements from an Array
Syntax:
ArrayUnique(sourceArray [,compMethod ])
MyArray(0)="my"
MyArray(1)="my"
MyArray(2)="my"
MyArray(3)="example
ArrayUnique(MyArray)
MyWord = "example"
MyArray(0)="my"
MyArray(1)="example"
Replace
Replaces specific words in a string with
new words that you specify
Syntax:
Replace(sourceArray as Variant, findArray as
Variant, replacementArray as Variant[, start as
Integer[, count as Integer[, compMethod as
Integer]]]) as Variant
ShellID
Starts another program and returns its task ID
Dim task_Id As Variant
task_Id = Shellid("calc.exe")
Print "Calculator task number = " & taskId
8
LS2J - LotusScript to Java
What does LS2J give you
ƒIntroduce
in Notes/Domino 6
a technology used by LotusScript to communicate with Java
ƒTreat OLE/COM and Java in a consistent fashion as external
objects
ƒBind the object to a reference variable at run time
ƒUse
ƒIs
ƒDon't
LS2J - Basics
LS2J - How to Use LS2J
the extensive Java library or any Java code
need to learn the Java syntax to use an existing Java
code
ƒDon't need to rewrite existing LotusScript application in Java
ƒHow
ƒWe
have dedicated an entire session on how to use LS2J in
detail. We are not going to repeat it here.
ƒInstead, we will do a quick review and focus on something new
that we have developed since last LotusSphere –how to use Java Library from LotusScript
to use LS2J
–in the option section
–put uselsx "*LS2J"
ƒLS2J
is implemented as an LSX
ƒThe "uselsx" statement will cause LS2J to load
ƒContains a collection of LotusScript classes to talk to Java
9
LS2J - Basic Classes
ƒBasic
LS2J - An Example
LS2J classes
–JavaSession - represents a connection to an instance of the JVM
–JavaClass - represents a Java class of the specified Java package
–JavaObject - represents an instance of Java class instantiated
–JavaError - represents Java Exceptions and errors.
Dim j as new JavaSession
Dim c as JavaClass
Dim o as JavaObject
Set c = j.getClass("com.ibm.lotus.myClass")
Set o = c.CreateObject()
'Now "o" references a real Java object
LS2J - What you can do with the object
ƒUse
the dot notation to
–get/set its property
–invoke its method
ƒSupport
method overloading
–get the right method by
matching the number of parameters
–matching the types
–not perfect, dependent on the JNI implementation
–
ƒFor
most users, that is all you need to do.
ƒExample
LS2J - DataType Mapping
LotusScript
Java
BYTE
byte
BOOLEAN
Boolean
INTEGER - 16 bit
short
LONG - 32 bit
integer
? long
FLOAT
float
DOUBLE
double
STRING
char, char[], String object
ARRAY
ARRAY
OBJECT
OBJECT
10
LS2J - Advance classes
LS2J - Where are your Java Classes
ƒJavaProperty
ƒIn
- represents a field in the Java class
- represents a method in the Java class
ƒJavaPropertyCollection/JavaMethodCollection
ƒJavaMethod
–represents a collection of all properties and methods for the Java
class
most cases, it is on the hard disk. For example, part of the
standard Java library. It comes as default.
ƒIt will look for it using the ClassPath and the default install
location for it.
ƒSince it is on disk, it assumes that the user has the right to put
the files on. So, it uses the system class loader to load the
specified class.
LS2J - What are the issues ?
LS2J - Script Library
ƒDeployment
ƒLotusScript
–need to install your Java classes on all your user's hard disk yourself
ƒSecurity
–assume that the user will take care of this as they must have access
to the disk to install the Java code.
- USE statement
Library - you can put your Java code in a script library
ƒPut the two concepts together
ƒScript
–USE "myJava-ScriptLibrary"
ƒSearch
Order
–still disk first
–will locate packages and classes in the Script Libraries in the order
they are loaded
11
LS2J - Security
ƒScript
library security rule applies
–administrator can sign the script library
LS2J - Example of using library
ƒExample
–at load time, it will merge the rights of all script libraries together
–at run time, it will check against the resultant rights - ECL check.
LS2J - Limitations
ƒlimitations
–LotusScript can call into Java easily
–Cannot pass a LotusScript object into Java for manipulation
–Java cannot call into LotusScript directly. The only way is through the
AgentRun method. It is due to the threading issues.
Web Services
ƒProvide
programmatic access to remote objects
OS and programming language independent!
ƒExtends the reach of your applications
ƒExposes your applications to the world
ƒPlatform,
Great
12
Call Remote Methods via SOAP -- (XML)
How Web Services Work
ƒThe
Simple Object Access Protocol
Consum
er
SOAP Request
SOAP Response
consuming (calling) application
a method call with parameters
ƒFormats the call as XML/SOAP text
ƒSends it via HTTP POST
ƒConstructs
Web
Service
Building Block
SOAP Protocol -- Request
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=
"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:getPrice
xmlns:ns1="urn:xmethods-BNPriceCheck"
SOAP-ENV:encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/">
<isbn xsi:type="xsd:string">0439139597</isbn>
</ns1:getPrice>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP Protocol -- Response
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=
"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<ns1:getPriceResponse
xmlns:ns1="urn:xmethods-BNPriceCheck"
SOAP-ENV:encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:float">15.57</return>
</ns1:getPriceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
13
SOAP Protocol -- Response (cont.)
Consuming a WS with Java or LS2J
ƒThe
consuming application gets the XML/SOAP response
the XML/SOAP response to get the result
ƒResult -- Book price is $15.57
ƒUnwraps
Notes or Domino
Agent
Web
Service
SOAP4J
HTTP
SOAP Java
API
SOAPConnect for LotusScript
Web Service Description Language (WSDL)
ƒFree
ƒXML
utility
file describes the service
–www.lotus.com/ldd
–Methods
–Search on "SOAPConnect"
–Parameters
ƒLotusScript
Library
–Data types
–URL of the service (end point)
ƒJava
Agent
ƒR5 and Notes/Domino 6
–etc.
Where
to
FIND it
14
Consuming a WS with COM (Windows only)
Notes or Domino
LotusScript
SOAP COM
API
WSDL
MS
SOAP
Toolkit
Weather Service
HTTP
created in Designer to hold data
MS SOAP Toolkit to build and send a request
ƒResponse came back
ƒExtracted price from response
ƒUpdated Lotus Notes document
ƒCalled
Demonstration
Web
Service
What We Just Saw
ƒForm
Real Web Service on xmethods.com
MS SOAP (think .net)Demo
ƒMS
SOAP (think .net)Demo
–Weather service on xmethods.com
–Call Web Service Form
Demo
15
What We Just Saw
Lotus Domino Application as a WS (Java or
COM)
ƒLotusScript
ƒAccessible
Created MS SOAP objects
URL for the WSDL file
ƒCreated proxies for Web Service methods
ƒCalled the Web Service
ƒPut result in Notes document
via
–Tom Cat
ƒCalled
–WebSphere
–Iplanet
–.Net
ƒOr
–100% Domino With LotusScript
Providing a Lotus Domino WS
100% Domino -- for Java
Providing a Lotus Domino WS
Domino
SOAP
Backend
classes
NSF
Your
Progra
m
Java/.net
Container
WS
Client
Domino
Backend
classes
SOAP
Web
Agent
WS
Client
LotusScri
pt
Library
NSF
16
Providing a Lotus Domino WS
100% Domino - for .NET
Domino
Backend
classes
SOAP
Web
Agent
Lotus Domino as a WS
Demonstration
WS
Client
LotusScri
pt
Library
NSF
.Net
Client
A Magic 8-Ball "DominoQuote"
WSDL
Read SOAP/XML POST Text
Web Agent Code
Set doc = s.DocumentContext
'...Get SOAP in...
SOAPin=
doc.GetItemValue("Request_content")(0)
' ...Tell Domino not to convert text to HTML
Print "Content-Type: text/xml"
Parse SOAP Document
Parse out the Name Space, Method Name,
and Argument being passed
(use DOM Parser in Release 6)
bodyPos= Instr(1,SOAPin,|<SOAP-ENV:Body>|)+15
methodPos= Instr(bodyPos,SOAPin,|:|)+1
methodEnd=Instr(methodPos,SOAPin,| |)
MethodName = Mid(SOAPin,methodPos,....)
nameSpacePos= Instr(methodEnd,SOAPin,|uri:|)+4
nameSpaceEnd=Instr(nameSpacePos,SOAPin,|"|)
NameSpace=Mid(SOAPin,nameSpacePos,(....
....
17
Running the Domino Web Service
Load LotusScript Library based on Name Space
Call LotusScript function based on Method Name
LSlib = NameSpace
Parameter = argValue
MyFunction = MethodName
Library= |"| & LSlib & |"|
Arg= |("| & Parameter & |")|
' load LotusScript Library and call the function
CallString = |Use | & Library & |
response = | & MyFunction & Arg
Execute CallString
Build SOAP Response and Send it to Client
strTmp = |<?xml version="1.0" encoding="UTF-8"_ standalone="no"?>|
&|<SOAP-ENV:Envelope ...
...
....
Print strTmp
Execute Statment
ƒCompiles
module.
and executes a text expression as a temporary
CallString = |Use | & Library & |
response = | & MyFunction & Arg
Execute CallString
What Did We See?
ƒClient
application sent request -XML/SOAP
processed request
ƒServer
–Established a Notes session
–Picked a random number
–Accessed a document in Domino DB
ƒPrint
XML/SOAP response to client
ƒClient displayed result
18
WSDL Tools
Related Presentations
ƒIBM
ƒAD402:
WebSphere Studio Application Developer
Web Services Toolkit
ƒMS Visual Studio .NET
ƒetc.
Adding a Web Services Interface to Your Lotus Domino
Applications. Tuesday, 1/28, 4:30
ƒAD205: Lotus Notes/Domino 6 Agents: Practical Guide to New
Features. Monday, 1/27, 3:15
ƒAD207: Lotus Domino 6 Objects By Example. Tuesday, 1/28,
12:15
ƒAD302: Lotus Domino Designer Advanced Topics. Tuesday,
1/28, 4:30, or Wednesday, 1/29, 2:30
ƒAD201: @Formula Language Tips and Techniques. Tuesday,
1/28, 4:30
ƒAD105: "Must Have" Additions to Your Lotus Notes 6 Client
Applications. Wednesday, 1/29, 10:30
ƒIBM
Tool
Questions & Resources
ƒWWW.Lotus.com/LDD
ƒIBM
Redbook
Questions?
19