Using XPages out of the box lets you build good-looking and well-performing applications. As XPage applications become bigger and more complex, performance can become an issue. There are several ways to improve scalability and performance that you should take into consideration. In this webinar, learn how to use partial refresh and partial execution mode and how to monitor its execution using a JSFLifeCycle monitor to avoid multiple re-calculations. See how readily available tools from OpenNTF will allow you to profile and analyze your code to improve the speed of your applications. Using Server Side Java Script and encountering a significant slow down when using Script Libraries? Learn how you can improve the speed of your application using JAVA instead of JavaScript, JSON and even @formulas.
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Â
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
1. The Autobahn Has no Speed Limit â Your XPages Shouldnât Either
Tweet about this event: #xpages
and mention us: @teamstudio @TLCCLTD @eknori
October 17, 2013
3. Who we are
⢠Our background is in creating tools for collaborative
computing in mid-size and large enterprises, primarily for
Lotus Notes
⢠Easy-to-use tools for developers and administrators
⢠2300+ active customers, 47 countries
⢠Offices in US, UK and Japan
⢠Entered mobile space in 2010 with Unplugged â easy
mobilization of Notes apps to Blackberry, Android and iOS
4. Teamstudio Unplugged
⢠Your Mobile Domino Server â take your Notes
apps with you!
⢠End users access Notes applications from
mobile devices whether online or offline
⢠Leverages existing skills and technology â
XPages â Replication model you already know
⢠IBM Collaboration Solutions Award Winner 2013
5. Teamstudio Continuity
â˘
Mobile BCM application for smartphones and tablets
â iOS, Android and BB
â˘
â˘
â˘
Offline access to all your BCM and
Disaster Recovery data
Store plans, contacts, call trees, and more
Client available for download from app stores
6. Teamstudio
⢠Next webinar November 19th
⢠DCLUG â October 24th
⢠BLUG All Things Mobile â October 29th
⢠Promotions:
â Chance to win an iPad mini when you get a demo of Teamstudio
Continuity
7. The Autobahn has no speed limit
- Your XPages shouldn't either!
Your Host Today:
Paul Della-Nebbia
TLCC
@PaulDN
#XPages
1
8. Upcoming and Recorded Webinars
Next Webinar on November 19th
www.tlcc.com/xpages-webinar
View Previous Webinars
(use url above)
2
9. TLCC Courses and Services
⢠The Leader in Notes and Domino Training since 1997
⢠Self Paced Distance Learning Courses for Notes/Domino
â XPages, Development, and Administration (user too!)
â Learn anywhere using your Notes client
â Many demos and activities
â An Instructor is a click away
⢠OnSite Private Classes
⢠TLCC Mentoring Services
3
10. Whatâs New at TLCC
ďź Free course â Introduction to XPages Development (both 8.5 and 9.0)
ďź New Courses!
⢠Notes Domino 9 Application Development 1
⢠Notes Domino 9 Application Development Update
⢠Java 1 for XPages Development (9.0)
⢠Notes Domino 9 System Administration Update
⢠Notes Domino 9 System Administration 1
ďź New Packages!
⢠XPages and JavaScript for Domino 9 Package
⢠XPages and Rapid Development for Domino 9 Package
⢠XPages, JavaScript and Rapid Development for Domino 9 Package
ďź TLCCâs Fall Sale â Extended to Oct. 31st
4
11. XPages Skills Path
Suggested TLCC Skills Path at TLCC.com
Core Notes/Domino
Skills
Domino Object
Model skills
LotusScript or
Java
Rapid XPages
Development (user
interface controls)
XPages
Development 2
JavaScript for
XPages Developers
XPages
Development 1
Mobile XPages
Development
Java for XPages
TLCC Can Help:
â˘
â˘
â˘
â˘
â˘
Self Paced Courses
Instructor Led Online
OnSite Private Instructor Led
Blended Learning
Custom courses
5
17. Hardware
⢠The hardware used has a significant influence on
performance. There are 3 key elements:
â CPU
â Main Memory
â Hard Disk
11
18. Hardware
⢠Main Memory
â Limit defined by the operating system
ď Scalability
⢠CPU
â Cores / Clock / Cache
ď Poor response time
⢠Weak CPU AND Low Memory
â Poor overall performance
â Poor response times
â Server "hangs"
12
19. Network
⢠Latency
â Time taken for data transmission between
multiple computers on a network
⢠Bandwidth
â Rate of transmission of data
⢠Greater Bandwidth
+ Lower Latency
-------------------------------= Better Connection
13
20. Client & Browser
⢠Hardware
⢠How many data requests / responses are
transmitted
⢠How much data is transferred (size)
⢠Caching of resources
⢠How much CSJS runs
⢠Size / complexity of the CSS
⢠Complexity of the site structure
14
21. Limiting factors on performance
⢠Browser / HTTP server
â Network latency â distance/time to server.
â Bandwidth â size of files.
â Browser limits on concurrent downloads
⢠IE7 allows 2 downloads, IE8 allows 6
⢠HTTP Server / App Server
â HTTP Server JVM heap size & garbage collector
â CPU time, competition between threads, gives slower
response times
â Threads, limited to 40 by default
15
22. Limiting factors on performance
⢠App Server / Domino context
â Read design elements from the NSF (XPage .class files, form
structure, etc)
â Backend API calls may be expensive, especially for large data
sets
â Design elements may be network requests
16
23. Limiting factors on performance
⢠Servlet / Lifecycle
â Restore control tree â file system read. Control tree locking
â no concurrent access
â Rendered re-evaluated for every control for most phases
⢠Browser/Client JavaScript/Dojo
â Inline JavaScript blocks insertion of later HTML elements
into the DOM tree
â Dojo does AJAX requests for .js files for dojo modules that
are not loaded
17
24. General Performance Options
⢠notes.ini
â HTTPJVMMaxHeapSizeSet=1
â HTTPJVMMaxHeapSize=256M
⢠Should be set to Ÿ of the available RAM
⢠Domino Administrator
â HTTP server Disable Logging
â HTTP server thread count defaults to 40
⢠link to IBM article
⢠Debugging enabled in notes.ini ?
â JavaEnableDebug=1
â JavaDebugOptions=transport=dt_socket,server=y,suspen
d=n,address=8000
â JavascriptEnableDebug=1
18
25. Reducing Memory Utilization
⢠xsp.persistence.mode=
â Defines the persistence mode for the JSF pages
⢠file: All the pages are persisted on disk
⢠fileex: All the pages are persisted on disk except the current one,
which stays in memory
⢠<else>: All the pages stay in memory (tree mode)
19
26. JavaScript/CSS Aggregation
⢠Groups many DOJO, CSS / JS files into a single file
â Less requests from the browser to the server
â Performance improvements on networks with high
latency
â Enhanced performance parsing CSS / JS
â Fewer connections to the server
On the Server: xsp.properties:
xsp.resources.aggregate=true
20
28. XPages PreLoad
⢠XPagesPreload=1
⢠New Feature in Notes / Domino 8.5.3
⢠Works on Server and Client
⢠Java classes from the XPages runtime plug-ins loaded
from a fixed list of runtime classes ( 435 in ND 8.5.3 )
â com.ibm.xsp.core, common utility, JS wrapper, FSF runtime
classes
⢠Java classes referenced in *-faces.config.xml
â XPages control renderer, data sources, complex types
22
29. XPages PreLoad
⢠XPagesPreloadDB =
Server!!Db.nsf/XPage.xsp, myLocalDb.nsf
⢠Works at the application level
⢠The application is loaded on the client / server startup into
memory
â This happens even when the application is first opened in
the browser
23
30. XPages PreLoad (cont.)
⢠For each entry in the notes.ini variable, an XPage
URL is generated and sent to the server
⢠The application is loaded, and the HTML generated
⢠The XPages runtime discards the HTML, but retains
the application in memory
24
31. Scoped Variables
⢠applicationScope
â Are visible for all users of one application
â Expires some time after the last user used an
applicationScope variable
â applicationScope variables are NOT persistent forever
⢠sessionScope
â Is valid through the session of the current user
â A user session expires after some time of inactivity
â Uses don't have access to the sessionScope variables of
other users
25
32. Scoped Variables (cont.)
⢠viewScope
â Is visible for views on the current page only.
â Useful for transporting a search query to a view.
⢠requestScope
â Is valid through one request of the current user.
â That includes refreshing of a page.
26
35. JSF Life Cycle - Post
Request
Restore View
â˘Restore component tree
â˘Events:
â˘afterRestoreView
Apply Request
Values
â˘Copy data to Editable
controls
Process Validations
â˘Validations
â˘Converters
Update Model
Values
â˘Move values to data
source
Invoke Application
â˘Application logic
â˘Events:
â˘onClientLoad (XPage,
etc)
â˘on⌠events of button,
etc.
Render Response
â˘Convert to HTML, etc.
â˘Events:
â˘beforeRenderReponse
â˘afterRenderResponse
Response
29
36. Lifecycle1 XPage â Initial Page Load
Render Response
⢠Rendered property for id: label1
⢠Label property for id: label1
⢠Rendered property for id: inputText1
⢠Default value property for id: inputText1
⢠Rendered property for id: label2
⢠Rendered property for id: comboBox1
⢠values property for id: comboBox1
⢠values property for id: comboBox1
⢠Rendered property for id: computedField1
⢠Value property for id: computedField1
⢠Rendered property for id: computedField2
⢠Value property for id: computedField2
30
37. Lifecyle1 â Submit (Full Update)
Restore View
Apply Request Values (8)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Update Model Values (8)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Invoke Application (1)
â˘OnClick event for id: button1
39 SSJS Calls
Process Validations (11)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Validation for inputText1
â˘Default value property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Render Response (11)
â˘Rendered property for id: label1
â˘Label property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Value property for id: computedField1
â˘Rendered property for id: computedField2
â˘Value property for id: computedField2
31
38. When to Execute - # vs $
<xp:label id="label1">
<xp:this.value>
<![CDATA[#{javascript:return âMy
Labelâ;}]]>
</xp:this.value>
</xp:label>
⢠# is Compute dynamically
â Executed every time the page is rendered
â Use for values that are likely to change
⢠$ is Compute on Page Load
â Executed when the page is first loaded
â Use for values that don't change
32
39. Lifecyle2 â Submit (Full Update) - On Page Load
Restore View
Changed all Rendered and
Values (comboBox) to only
compute on Page Load
Update Model Values
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Apply Request Values
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Invoke Application (1)
â˘OnClick event for id: button1
6 SSJS Calls, saved 33
Process Validations (2)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Validation for inputText1
â˘Default value property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Render Response (3)
â˘Rendered property for id: label1
â˘Label property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Value property for id: computedField1
â˘Rendered property for id: computedField2
â˘Value property for id: computedField2
33
40. But I need dynamic Rendering!
Options for dynamically computing the Rendered:
⢠Scoped variables
â Still get calculated but do the heavy lifting once and then
read the scoped variable in the Rendered property
⢠DataContexts
â Compute a value at the Xpage or Panel level once
â Refer to the value using EL (much faster than SSJS)
34
41. DataContext
⢠Can be thought of as global variables
⢠Value can be computed dynamically or on page load
â Warning: Computing dynamically has performance impact
⢠Can be scoped to any level that a data source can
â XPage, Custom Control or Panel
â Set a dataContext in a panel in a repeat control to avoid
multiple references to a NotesDocument's item
⢠Can be referenced using EL
â Benefit: Not having to go through the SSJS parser
35
42. DataContext - Pitfall
⢠Be careful binding data context variables dynamically
â They will be recomputed multiple times, even when in
partial execution mode and if they are not in use (six
times!)
⢠Apply Request Values
⢠Process Validations
⢠Update Model Values
⢠Invoke Application
⢠Twice in Render Response!
⢠If computed on page load then only computed once on page
load
⢠See Paul Withers blog entry to learn how to set a data context
value via code
36
43. Partial Refresh vs. Partial Execution?
⢠Partial Refresh (Update)
â Computes entire XPage,
only sends back what is
in the partial refresh id
(refreshId)
⢠Partial Execution
â Only calculates what is in
the area specified
(execId)
37
44. Partial Refresh Demo - Results
Restore View
Apply Request Values (8)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Update Model Values (8)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Invoke Application (1)
â˘OnClick event for id: button1
Only Savings
were here!
30 SSJS Calls, saved 9
Process Validations (11)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Validation for inputText1
â˘Default value property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Render Response (2)
â˘Rendered property for id: label1
â˘Label property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Value property for id: computedField1
â˘Rendered property for id: computedField2
â˘Value property for id: computedField2
38
45. Partial Refresh Pros and Cons
⢠Pros
â Reduced control processing in the render response phase
â Smaller response from server
⢠Means reduced network usage
â Better UI experience
⢠Rest of the page is still visible while waiting for a response
⢠Cons
â Controls like computed fields outside refresh area donât refresh
â Be careful turning this on for a completed XPage (TEST!)
â Can only update one area (one id)
⢠Workaround on Tim Tripcony blog here
39
46. Partial Execution Demo - Results
Restore View
16 SSJS Calls
Saved 13
Update Model Values (1)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Apply Request Values (1)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Invoke Application (1)
â˘OnClick event for id: button1
Process Validations (1)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Validation for inputText1
â˘Default value property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Render Response (12)
â˘Rendered property for id: label1
â˘Label property for id: label1
â˘Rendered property for id: inputText1
â˘Default value property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Value property for id: computedField1
â˘Rendered property for id: computedField2
â˘Value property for id: computedField2
40
47. Partial Execution Pros and Cons
⢠Pros
â Reduced processing in the 3 data-processing phases
⢠Cons
â Control with onClick event has to be inside the execId area
â Editable values outside of the executed area do not get
submitted/updated (reset to default values)
â Existing XPages need analysis/testing before using this
⢠Current onclick events might refer to controls where the data
is not submitted
â ExecMode available in 8.5.1
â Have to use source to enter ExecId (in 8.5, 9.0 has Designer UI)
41
48. Partial Refresh AND Execution Demo - Results
Restore View
Apply Request Values (1)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
â˘Rendered property for id: computedField2
Update Model Values (1)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Invoke Application (1)
â˘OnClick event for id: button1
6 SSJS Calls,
saved 33
Process Validations (1)
â˘Rendered property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: inputText1
â˘Validation for inputText1
â˘Default value property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Rendered property for id: computedField2
Render Response (2)
â˘Rendered property for id: label1
â˘Label property for id: label1
â˘Rendered property for id: inputText1
â˘Rendered property for id: label2
â˘Rendered property for id: comboBox1
â˘values property for id: comboBox1
â˘values property for id: comboBox1
â˘Rendered property for id: computedField1
â˘Value property for id: computedField1
â˘Rendered property for id: computedField2
â˘Value property for id: computedField2
42
49. disableValidators= true
â˘
â˘
â˘
â˘
All phases (1-6) occur
Turns off all validators
Converters continue to work
Items in documents will be updated
Restore View
Apply Request
Values
Process
Validations
Update Model
Values
Invoke
Application
Render
Response
â˘No Validators get
executed here!
43
50. Immediate = true
⢠JSF Lifecycle processes only phases
(1, 2, 6)
⢠No data processing
⢠Items in documents are not
updated
⢠Onclick event handler scripts and
render response calculations are
performed
Restore View
Apply Request
Values
Process
Validations
Update Model
Values
Invoke
Application
Render
Response
44
51. Using the loaded Property
Loaded only computed once in the createView phase
⢠Loaded = true
â Not in component tree or
memory
⢠Loaded = false
â Control is not created
â Can never be rendered
or accessed
â Saves memory too
45
52. Life Cycle Performance Suggestions
⢠Most properties, like CSS âstyleâ are
only computed in the
RenderResponse phase
⢠Watch and minimize:
â Rendered property (when dynamic)
⢠Computed multiple times!
⢠Use dataContexts or scoped variables
when able
⢠Use both Partial Refresh (Update)
and Partial Execute when able
46
53. Watch Out for @DbLookup
⢠@DbLookup about 3-4 times slower than SSJS
â res = @DbLookup(db,"CustomersByNameView",names[i], "phone");
vs.
â doc = vw.getDocumentByKey(names[i], true);
res = doc.getItemValueString("phone");
⢠Five lookups repeated 100 times
â @DbLookup averaged about 1728ms
â getDocumentByKey averaged 510ms
⢠Other @Functions not tested
47
55. Images
⢠Use correct file type depending on content
â JPEG for complex and detailed images
â PNG/GIF for simple images, fonts, transparencies
⢠Use the HTML <img> tag âwidthâ and âheightâ attributes
⢠For faster HTML layout in the browser
â Size the image to size you intend to use
⢠Resizing using html attributes height and width will delay the
rendering of your page
⢠Images larger than necessary will waste bandwidth
49
56. Image Sprites
⢠Use CSS Image Sprites
â If you have multiple small images, make a single larger
image containing the smaller images
â Use CSS to display only the relevant subset image at a
location in the page
â For semantically significant sprites, provide an
accessibility âtitleâ attribute (as sprites don't use the
IMG âaltâ attribute, but you still want to assist blind
users)
â There's no specific XPages support for sprites, but
they're used in the XPages OneIU themes
50
58. XPages Toolbox
⢠XPages based Application
â Runs on the Domino server or the Notes client
â An NSF needs to be installed on the server/Notes client
â A profiler jar file should be added to the JVM launch options
⢠Measures CPU performance and memory allocation
⢠Available from OpenNTF.org
â Free open source project
⢠http://www.openntf.org/internal/home.nsf/project.xsp?action=open
Document&name=XPages%20Toolbox
⢠Extended in 8.5.2 to support backend classes profiling
52
60. XPages Toolbox
⢠Generate a heap dump of the JVM running in the HTTP
task
â A button in the XPages profiler generates the heap dump
â From the Domino console
⢠tell http xsp heapdump (triggers com.ibm.jvm.Dump.HeapDump())
⢠tell http xsp javadump (triggers com.ibm.jvm.Dump.JavaDump())
⢠Analyze the heap dump using the Eclipse memory
analyzer
â http://www.eclipse.org/mat/
â http://www.ibm.com/developerworks/java/jdk/tools/dtfj.html
54
62. More Tools
⢠Print statements
â In rendered/visible computations to see how often executed
⢠print("panel2 evaluating rendered property");
â In the XPages root control events:
⢠before/afterPageLoad, afterRestoreView,
before/afterRenderResponse
â Custom control root events:
⢠before/afterPageLoad
â In the document data source events:
⢠queryNewDocument, postSaveDocument, etc.
⢠Task Manager and/or Process Explorer
â Shows CPU usage & process memory usage as it happens
56
63. More Tools
⢠Browser developer tools
â for watching network transactions, partial updates,
response times
â BROWSER: Firebug, Developer Tools
â XPiNC: FirebugLite from ExtLib
⢠Java / Javascript Debugging
â Degrades performance but can inspect objects
⢠Use the Eclipse Java debugger
â In Dominonotes.ini add these 2 options:
⢠JavaEnableDebug=1
⢠JavaDebugOptions=transport=dt_socket,server=y,suspend=n,add
ress=8000
57
65. Step 1: Original Code From Sample
⢠Read all Contacts into a NotesDocumentCollection,
loop the collection and build the JSON by reading
the values from items in the document
59
67. Step 2: Store UNID in an item
⢠Get all Contacts into a NotesDocumentCollection,
loop the collection and build the JSON by reading
the values from items in the document. Also UNID
is stored in document
61
69. Step 3: Build JSON on document save
⢠Get all Contacts into a NotesDocumentCollection, loop
the collection and get the JSON from an item on the
document. JSON is calculated on document save
63
73. StringBuilder vs String.concat
⢠Concatenation of Strings is very easy in Java - all you
need is a +
⢠Each time you append something via + (String.concat())
a new String is created, the old stuff is copied, the new
stuff is appended, and the old String is thrown away.
The bigger the String gets the longer it takes - there is
more to copy and more garbage is produced.
⢠Accordingly to Arno Unkrig the optimal strategy is to
use String.concat() for 2 or 3 operands, and
StringBuilder for 4 or more operands
67
74. StringBuilder vs String.concat
⢠Use StringBuilder whenever you assemble a String in a
loop
â Keep in mind that + isn't always a good idea
68
75. Step 5: Use a StringBuilder to concat the JSON
69
79. Homework Time â Further References
⢠IBM article on JSF (non XPages)
⢠Paul Withers blog (each link below is different)
â Part 1, Part 2, Part 3
⢠Tony McGuckinâs Video - XPages Master class
â 4 videos plus sample applications
73