SlideShare a Scribd company logo
10 Mistakes
You and Every XPages
Developer Make
(Yes, I said YOU!)
Serdar Başeğmez (@sbasegmez)
Developi Information Systems
1#engageug
Serdar Başeğmez
• IBM Champion (2011-2015)
• Developi Information Systems, Istanbul
• Contributing…
• OpenNTF / LUGTR / LotusNotus.com
• Featured on…
• The View, NotesIn9
• Presented at…
• IBM Connect and LUGs
• Also…
• Blogger and Podcaster on Scientific Skepticism
2#engageug
Today
• Why are we here?
• Revisiting some key concepts
• Browser-Server interaction
• Repeat Control
• Custom Controls
• Dialogs
• Managed Beans
• Java
3#engageug
This Session is About…
• Problems of XPages developers.
• Some from personal experience
• Workshops, conversations, other XPages apps, etc.
• Some from Stackoverflow…
• Downloaded all Stackoverflow Q&A on #XPages tag.
• Filtered code, applied some linguistic magic
• Analyzed the most common word couples used together
(NGram Analysis).
4#engageug
What Topics Asked in Stackoverflow…
5#engageug
The most common
keywords in all questions
from StackOverflow…
It’s XPages…
not xpages or Xpages or xPages 
6#engageug
Component Tree,
View and Page States
revisiting some key concepts
7#engageug
8#engageug
Root Component (Global «view» variable)
Collects all JavaScript imports used throughout the page.
Automatically added by default…
Some components does not inject all children initially
Event Handlers are components too
9#engageug
Components and Component Tree
• Every Component is Java magic…
• Component is a Java Object.
• Generally, it has a different renderer.
• Sometimes it has other helper classes.
• Component Tree is an hierarchical representation
• ‘Prepared’ during page load, ‘Revised’ between JSF phases.
10#engageug
11#engageug
Old Component State:
Display documents 1 to 30
New Component State:
Display documents 31 to 60
Page State
• A page has a lifecycle in the server.
• Persists its state as a component tree
• Component tree also contains viewScope
• Page State is stored on Disk or Memory
• Disk: Good for Scalability
• Memory: Good for Performance
• Only the current page in memory: Optimized
• One page per each user kept in memory.
12#engageug
XPages Stateful Architecture
13#engageug
XPages State Manager
request
response
XPages ApplicationBrowser
NSF
DATA
read/write
previous state
save state
Each request contributes into a previous state…
JSF Lifecycle
what happens under the cover?
14#engageug
Full Request – Response Lifecycle
15#engageug
Restore
View
Apply Request
Values
Process
Validations
Update Model
Values
Invoke
Application
Render
Response
Process
Events
Process
Events
Process
Events
Process
Events
Request
Response
Response
Complete
Response
Complete
Response
Complete
Response
Complete
Validation/Conversion Errors
Conversion Errors
Do not update/validate (immediate)
Full Request – Response Lifecycle
16#engageug
Prepare Page
Render
Response
beforePageLoad
Request Response
afterPageLoad
First Time
Page Load
GET Requests – Lifecycle
17#engageug
Restore
View
Render
Response
GET
Request
Response
SKIP ALL PHASES
Immediate Lifecycle
18#engageug
Restore
View
Apply Request
Values
Render
Response
Process
Events
Request
Response
Response
Complete
Do not update/validate (immediate)
SKIP SOME PHASES
No update for model (e.g. Domino Document)
Lifecycle for Validation Error
19#engageug
Restore
View
Apply Request
Values
Process
Validations
Render
Response
Process
Events
Process
Events
Request
Response
Response
Complete
Response
Complete
Response
Complete
Response
Complete
Validation/Conversion Errors
SKIP UPDATE VALUES
No data written into the model (e.g. Domino Document)
Why Lifecycle is so Important…
• Performance, scalability, etc.
• Between phases, dynamic values are computed many times
• Combine Lifecycles and Partial Execute model
• Don’t underestimate the load of hundreds of users.
• If no need for any update, use immediate.
• If no need for any validation, skip validation.
• More information on links…
• Troubleshooting very simple problems!
• Validation/Update issues during Partial Refresh
• e.g. when you use .getValue() or .getSubmittedValue()?
#engageug
Dynamic or not: #{…} vs. ${…}
• #{…} bindings run whenever time they needed
• Once at start, once between almost all phases!
• Root causes of many performance issues.
• Large view lookups for a combobox selection list?
• ${…} bindings run when the page is loaded
• At the time XSP prepares the page tree.
• Once in the entire lifecycle of the page.
• Mandatory for some attributes (e.g. «loaded»).
21#engageug
"rendered" vs. "loaded"
22#engageug
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:label
value="Here is a Hidden CC:"
id="label1">
</xp:label>
<xc:ccBasic
rendered="#{javascript:return false;}">
</xc:ccBasic>
<xc:ccBasic
loaded="${javascript:return false;}">
</xc:ccBasic>
</xp:view>
When a CC included into the tree,
${…} bindings and page events will be evaluated!
XSP ignores this CC…
XPages Scopes
Scope Validity Deletion
Application Global*
(* Except local XPiNC apps)
Idle timeout of the app.
(xsp.application.timeout – 30 mins)
Session Per browser session Idle timeout of the session (**)
(xsp.session.timeout – 30 mins)
View Entire lifecycle of pages Limited number of Pages per user
(Disk: xsp.persistence.file.maxviews – 16)
(Mem: xsp.persistence.tree.maxviews – 4)
Request A single request After Response Complete
23#engageug
Application and Session scopes consume JVM memory… Cache wisely!
XPages Scopes
• SessionScope is a Browser session
• It’s not related to authentication. Just a cookie…
• Same user from different browser = Different Session
• When you close the browser, you lose the session access.
• If you logoff, things get complicated!
• If anonymous access enabled, sessionScope cleared.
• If another user logs in, sessionScope persists!
• A big issue while testing the code with different users.
• All Scopes are defined per NSF application…
• One application cannot access scopes of another!
• NSF application is where your XPages code runs.
24#engageug
Browser – Server
Interaction
two sides of the same coin
25#engageug
Browser – Server Interaction
• Understanding the XSP object…
• CSJS API for browser-server interaction
• Provides basic AJAX functionality
• Checks preconditions, errors and timeouts, Aggregates
necessary header and POST content, Guarantees only
one AJAX request at a time,
• Widgets extend XSP for additional functionality
• e.g. dialog adds openDialog(…) and closeDialog(…)
• Event Handlers attach JavaScript to components
26#engageug
27#engageug
Server Zone Client Zone
XSP Manager
Components
Renderers
Push
HTML + CSJS
Plugins
UI Objects
(DOM)
Buttons, inputs, etc.
XSP Object
User Actions / Events
FacesServlet
AJAX Request
GET/POST
Build a New State
<xe:dialog/>
a potential code-breaker in wrong hands…
28#engageug
The heir of the Dojo Dialog
• Ext.Lib. Dialog is an extended Dojo Dialog…
• Dojo Dialog is incompatible to the XPages.
• Dojo injects the dialog out of the <form> tag.
• From XPages standpoint, this is a problem.
• So Ext.Lib uses a custom interaction mechanism for
dialogs.
• Dialog Component as an Example
• Open/Close dialogs from SSJS or CSJS???
• Let’s zoom at what’s going on with the Dialog…
29#engageug
A Basic Page with a Dialog
30#engageug
XSP.openDialog("#{id:myDialog}")
XSP.closeDialog("#{id:myDialog}", "#{id:myForm}")
<script type="text/javascript">
function view__id1__id13_clientSide_onclick(thisEvent) {
XSP.openDialog("view:_id1:myDialog")
}
XSP.addOnLoad(function() {
XSP.attachEvent("view:_id1:_id13", "view:_id1:button1",
"onclick", view__id1__id13_clientSide_onclick, false, 2);
});
</script>
Showing Dialog via CSJS
31#engageug
Where is the value???
• XSP.openDialog() sends a GET request
• The dialog prepares the contents
• The response is added to the DOM.
Common Issues with Dialogs
• When we open a dialog from CSJS…
• XSP.openDialog() sends a GET request to the server
• The dialog prepares the contents and sends back.
• The result is added to the DOM.
• It DOES NOT submit any value to the server…
• Server is not aware of any changes in other field values.
• Almost the same when you close the dialog…
• XSP.closeDialog(dialogId, refreshId): Closes the dialog and
partially refresh a component. No POST request!
• Use SSJS if you need to submit values…
32#engageug
Common Issues with Dialogs
• Using SSJS to open/close dialogs
33#engageug
<xp:button
value="Open Dialog SSJS"
id="button3">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="button3"> <!– It should refresh something! -->
<xp:this.action><![CDATA[#{javascript:
getComponent("myDialog").show()
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button
value="SSJS Close"
id="button4">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="myForm"> <!– We refresh the form so it reflects changes -->
<xp:this.action><![CDATA[#{javascript:
getComponent("myDialog").hide()
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
Common Issues with Dialogs
• If you really need to use CSJS…
• You can initiate a POST request first.
34#engageug
<xp:button
value="Open Dialog CSJS"
id="button1">
<xp:eventHandler
event="onclick"
submit="false">
<xp:this.script><![CDATA[
XSP.partialRefreshPost("@none", {
"onComplete": function() {
XSP.openDialog("#{id:myDialog}");
}
});
]]></xp:this.script>
</xp:eventHandler>
</xp:button>
• Submit a POST request
• Refresh no element (refresh needed on close)
• When you’re done, launch my dialog…
• Attention: It took two AJAX requests!
Common Issues with Dialogs
• Need a single value? Here is a trick…
• You can provide parameters to the dialog on CSJS…
• XSP.openDialog(dialogId, dialogOptions, dialogParams)
35#engageug
<xp:button
value="Open Dialog"
id="button1">
<xp:eventHandler
event="onclick"
submit="false">
<xp:this.script><![CDATA[
XSP.openDialog(
"#{id:myDialog}", /* dialogId */
{}, /* options */
{"tab" : "tab1" } /* params */
);
]]></xp:this.script>
</xp:eventHandler>
</xp:button>
Adds a query string parameter
to the GET request…
(…)
<xp:tabbedPanel id="tabbedPanel1" selectedTab="#{param.tab}">
(…)
We can use it
within the dialog…
<xp:repeat/>
what’s wrong with this mysterious component?
36#engageug
The Basics of <xp:repeat/>
• Repeat component iterates its child components
• «value» attributes should be an iterable component
(collection, array, list, etc.)
• «first» and «rows» attributes for the start index and count.
• It can be binded to any pager component.
• Renders "header" and "footer" facets.
• Repeat has two modes
• DataIterator mode (default)
• Repeat mode (when «repeatControls="true"»)
37#engageug
<xp:repeat
id="repeat2" var="value"
repeatControls="true"
value="#{repeatValues}">
<xp:this.facets>
<xp:label xp:key="header" value="START:" />
<xp:label xp:key="footer" value=":END" />
</xp:this.facets>
<xp:image id="image2" url="#{value}" />
</xp:repeat>
Two Modes of <xp:repeat/>
38#engageug
<xp:repeat
id="repeat1" var="value"
value="#{repeatValues}">
<xp:this.facets>
<xp:label xp:key="header" value="START:" />
<xp:label xp:key="footer" value=":END" />
</xp:this.facets>
<xp:image id="image1" url="#{value}" />
</xp:repeat>
Does not inject new components.
Only one set of child components, render multiple times
Injects multiple containers for every iteration.
Implications of «repeatControls»
• Child component limitations in DataIterator mode:
• ${…} bindings will be processed only once.
• ${…} bindings cannot consume repeat variables.
• ${value} will be ignored.
• ${javascript:value} will throw error.
• Repeat mode:
• Provides computed id’s for iterated fields (e.g. Radio)
• Iterated columns for Data Tables
• Limitation: Child elements are fixed, can’t be changed later.
39#engageug
<xc:customControls/>
do you miss subforms?
40#engageug
Custom Controls
• Specific to XPages…
• IBM’s implementation of JSF Composite Components.
• Similar to Subforms (but much better!)
• Injects XPages into your XPages…
• Custom Controls are XPages…
• Reusable components with their own xsp-config files.
• They support parameters, designer extensions, etc.
41#engageug
‘Multiple Choice’ Custom Controls
• Among multiple CCs, one will be displayed.
• If you can decide before loading page…
• URL parameter, user role, data source, etc.
• Static «loaded» can be used…
• Want to switch during run-time?
• According to an input, based on a dynamic value, etc.
• Dynamic «rendered» values preferred mostly.
• BUT, as shown before, this will evaluate the CC!
• All ${…} bindings and pageLoad events
42#engageug
A Better Approach: <xe:dynamicContent>
43#engageug
<xe:dynamicContent
id="dynamicContent1"
defaultFacet="cc01">
<xp:this.facets>
<xc:ccBasic
xp:key="cc01"
id="myCC_01"></xc:ccBasic>
<xc:ccBasic
xp:key="cc02"
id="myCC_02"></xc:ccBasic>
</xp:this.facets>
</xe:dynamicContent>
After switching…
<xp:button
value="Switch Dynamic Content"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action>
<xe:changeDynamicContentAction
for="dynamicContent1"
facetName="cc02">
</xe:changeDynamicContentAction>
</xp:this.action>
</xp:eventHandler>
</xp:button>
Common Issues for Custom Controls
• Black box approach with Custom Properties…
• Prioritize Reusability.
• Do not hardcode ‘things’ inside your custom control…
• Parent XPage – Custom Control interactions
• Interact to the data sources or components from the
parent XPage
• Trigger an event from the parent XPage?
44#engageug
45#engageug
<xp:inputText
id="inputText1"
value="#{compositeData.dataSource[compositeData.fieldName]}">
<xp:eventHandler
event="onchange“ submit="true"
refreshMode="partial“ refreshId="#{compositeData.onChangeRefreshId}">
<xp:this.action><![CDATA[#{javascript:
var handler = compositeData.onChange;
if(null!=handler && typeof(handler)=='com.ibm.xsp.actions.ExecuteScriptAction') {
handler.setParamNames(['value']);
handler.invoke(facesContext, [this.getParent().getValue()]);
}
}]]></xp:this.action>
</xp:eventHandler>
</xp:inputText>
A Custom Control
Reuses an inputText for a
special purpose
46#engageug
<xc:ccInput
dataSource="#{document1}"
fieldName="field1"
onChangeRefreshId="computedField1">
<xc:this.onChange>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:
print("Field1 >>> " + value);
]]></xp:this.script>
</xp:executeScript>
</xc:this.onChange>
</xc:ccInput>
Using Custom Control
Managed Beans
- approaching to the Java zone -
47#engageug
Managed Beans - Basics
• JavaBean is a simple Java class…
• Empty constructor, Serializable
• Has Getter and Setter methods to access its private fields
• Managed Bean is a JavaBean that is managed.
• It has a name and scope definition.
• The platform is responsible of the lifecycle.
• They are created on their first use…
• Single Instance guaranteed, but not Thread-safe!
• Managed Beans should be Serializable!
• It’s a MUST for the View Scope
• Best Practice in General!
48#engageug
Common Issues with Managed Beans
• Error handling in Constructor…
• Managed beans are instantiated via Reflection (long story).
• If constructor fails, it throws meaningless errors.
• No stack trace for constructor exceptions!
• USE a proper try-catch block in your constructor.
• It’s important to provide an informative message.
• Have an error page and/or logging mechanism…
49#engageug
public Bean01() {
Database myDb = ExtLibUtil.getCurrentDatabase();
try {
View myView = myDb.getView("Test01");
Document myDoc = myView.getDocumentByKey("key");
// ... do stuff
} catch (NotesException e) {
e.printStackTrace();
}
}
javax.faces.FacesException: javax.faces.FacesException: Can't
instantiate class: 'demo.Bean01'.. java.lang.ClassNotFoundException:
class java.lang.NullPointerException: null
Common Issues with Managed Beans
50#engageug
public class Bean01 implements Serializable {
private static final long serialVersionUID = 1L;
private long timeCreated;
private ApplicationSetupBean appSetup;
private DocumentCollection cachedDocs;
private transient Database myDb;
public Bean01() {
// Stuff
}
// Some other stuff
}
Do not store other beans!
Never Store Domino Objects!
Transient is also a bad idea!
Common Issues with Managed Beans
• «Do-not-store-these» within managed beans.
• Never store ANY Domino objects!
• Domino objects has C-handles on back-end. They will be
recycled after each request-response cycle.
• Only for view-scoped beans, you can define transient
fields but it’s a bad habit!
• Always store the reference (UniqueId, dbPath, etc.)
• Never store another bean or static Java object.
• During lifecycle or design-change objects might be
reconstructed.
• Many of these objects are cheap to reproduce!
51#engageug
Common Issues with Managed Beans
• Memory usage concerns are frequently asked.
• Especially important for caching beans…
• Application and session scope beans live in the memory
• View scope beans are stored in either memory or disk
• It depends on the persistence setting.
• Request scope is short-lived.
• Cost-benefit analysis for using memory vs. time
• Caching more information needs more memory.
• Not caching anything is processing time and I/O activity
• Get creative 
52#engageug
Use of Java
welcome to the magical world
53#engageug
Latin Small Letter Dotless-i
• “.toLowerCase()” and “.toUpperCase()”
• “DOMINO”.toLowerCase() = “domıno” on my server!!!
• Use Locale parameter… e.g. “.toLowerCase(Locale.US)”
• There are millions of computers with Turkish locale! 
54#engageug
Don’t kill me…
i  İ
I  ı
55#engageug
For this section…
If you use OpenNTF Domino API…
Smile towards others
Common Issues with Java
• Recycle… Recycle… Recycle…
• Domino objects keep a backend C-handle. It’s limited!
• Recycle every Domino objects you have used,
• …except Session and the current database…
• Recycle in «finally {…}» section.
• Also recycle in SSJS.
• Tired of recycling?
• Use OpenNTF Domino API…
56#engageug
Remember, there is a great team behind the Project.
…and they will be thirsty tonight 
Resources
additional readings
57#engageug
Books
• Mastering XPages 2nd Edition
http://www.redbooks.ibm.com/Redbooks.nsf/ibmpressisbn/9780133373370?Open
• XPages Portable Command Guide
http://www.redbooks.ibm.com/Redbooks.nsf/ibmpressisbn/9780132943055?Open
• XPages Extension Library
http://www.redbooks.ibm.com/Redbooks.nsf/ibmpressisbn/9780132901819?Open
58#engageug
XPages Request Process Lifecycle (X-RPL)
• Blog Series: Understanding Partial Execution, Paul S. Withers
• Part One – Refresh
http://www.intec.co.uk/understanding-partial-execution-part-one-refresh/
• Part Two – Execution
http://www.intec.co.uk/understanding-partial-execution-part-two-execution/
• Part Three – JSF Lifecycle
http://www.intec.co.uk/understanding-partial-execution-part-three-jsf-lifecycle/
• Also check these XSnippets by Tony McGuckin:
• XPages Request Processing Lifecycle explorer code
http://openntf.org/XSnippets.nsf/snippet.xsp?id=xpages-request-processing-lifecycle-explorer-code...
• dynamicContent - Efficient loading/rendering of a Component Tree
http://openntf.org/XSnippets.nsf/snippet.xsp?id=dynamiccontent-efficient-loadingrendering-of-a-component-tree
59#engageug
Performance and Scalability
• IBM ConnectED 2015 - MAS103 XPages Performance and Scalability,
Paul S. Withers & Tony McGuckin
http://www.slideshare.net/paulswithers1/mas103-xpages-performance-and-scalability
• XPages Performance: pro tips, Nathan T. Freeman
https://nathantfreeman.wordpress.com/2013/04/12/xpages-performance-pro-tips
• BLUG 2013: Life In The Fast Lane: Full Speed XPages, Ulrich Krause
http://www.slideshare.net/eknori/blug-2013final
• XPages Tip: Realizing the Cost of a Value Binding, Serdar Basegmez
http://lotusnotus.com/lotusnotus_en.nsf/dx/xpages-tip-realizing-the-cost-of-a-value-binding....htm
60#engageug
Miscellaneous
• IAmLug 2013: Managed Beans: When, Why and How, Russel Maher
http://www.slideshare.net/RussellMaher/managed-beans-when-why-and-how
• Tim Explains: SSJS Object Persistence, David Leedy
http://www.notesin9.com/2014/05/20/tim-explains-ssjs-object-persistence/
• Meet the XSP object, Stephan H. Wissel
http://www.wissel.net/blog/d6plinks/SHWL-878B9D
• Stackoverflow Answer to "What is the best way to recycle Domino
objects in Java Beans", Tim Tripcony
http://stackoverflow.com/a/11160925/1167922
• Stackoverflow Answer to "recycle domino objects after they are lost",
Paul S. Withers
http://stackoverflow.com/a/28827606/1167922
61#engageug
Miscellaneous
• Accessing the Value of Components within a Repeat Control from
Outside, Brad Balassaitis
http://xcellerant.net/2013/07/29/access-repeat-components-from-outside
• Why it is important to use the Recycle() method on every Java object
http://www-01.ibm.com/support/docview.wss?uid=swg21097861
• Sessions, logout, sessionScope and userScope, Paul S. Withers
http://http://www.intec.co.uk/sessions-logout-sessionscope-and-userscope/
• "Dotless i", toLowerCase and toUpperCase functions: Use responsibly!,
Serdar Basegmez
http://lotusnotus.com/lotusnotus_en.nsf/dx/dotless-i-tolowercase-and-touppercase-functions-use-
responsibly.htm
62#engageug
The End
ask questions now
get social later
@sbasegmez
63#engageug

More Related Content

What's hot

Domino policies deep dive
Domino policies deep diveDomino policies deep dive
Domino policies deep dive
Martijn de Jong
 

What's hot (20)

Running Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
Running Kafka On Kubernetes With Strimzi For Real-Time Streaming ApplicationsRunning Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
Running Kafka On Kubernetes With Strimzi For Real-Time Streaming Applications
 
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops TeamTop-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
Top-10-Features-In-MySQL-8.0 - Vinoth Kanna RS - Mydbops Team
 
Simplifying The S's: Single Sign-On, SPNEGO and SAML
Simplifying The S's: Single Sign-On, SPNEGO and SAMLSimplifying The S's: Single Sign-On, SPNEGO and SAML
Simplifying The S's: Single Sign-On, SPNEGO and SAML
 
dominocamp2022.t1s1.dde.pptx
dominocamp2022.t1s1.dde.pptxdominocamp2022.t1s1.dde.pptx
dominocamp2022.t1s1.dde.pptx
 
Introduction to Nginx
Introduction to NginxIntroduction to Nginx
Introduction to Nginx
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
Java for XPages Development
Java for XPages DevelopmentJava for XPages Development
Java for XPages Development
 
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
 
Everything You Need to Know About HCL Notes 14
Everything You Need to Know About HCL Notes 14Everything You Need to Know About HCL Notes 14
Everything You Need to Know About HCL Notes 14
 
IBM Domino / IBM Notes Performance Tuning
IBM Domino / IBM Notes Performance Tuning IBM Domino / IBM Notes Performance Tuning
IBM Domino / IBM Notes Performance Tuning
 
XPages Workshop: Concepts And Exercises
XPages Workshop:   Concepts And ExercisesXPages Workshop:   Concepts And Exercises
XPages Workshop: Concepts And Exercises
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics
 
Engage2022 - Domino Admin Tips
Engage2022 - Domino Admin TipsEngage2022 - Domino Admin Tips
Engage2022 - Domino Admin Tips
 
Domino Server Health - Monitoring and Managing
 Domino Server Health - Monitoring and Managing Domino Server Health - Monitoring and Managing
Domino Server Health - Monitoring and Managing
 
Replacing Your Shared Drive with Alfresco - Open Source ECM
Replacing Your Shared Drive with Alfresco - Open Source ECMReplacing Your Shared Drive with Alfresco - Open Source ECM
Replacing Your Shared Drive with Alfresco - Open Source ECM
 
Spnego configuration
Spnego configurationSpnego configuration
Spnego configuration
 
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-Reloaded
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-ReloadedRNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-Reloaded
RNUG - HCL Notes 11.0.1 FP2 — Performance Boost Re-Reloaded
 
How WebAssembly is changing the Web and what it means for Angular
How WebAssembly is changing the Web and what it means for AngularHow WebAssembly is changing the Web and what it means for Angular
How WebAssembly is changing the Web and what it means for Angular
 
Daos
DaosDaos
Daos
 
Domino policies deep dive
Domino policies deep diveDomino policies deep dive
Domino policies deep dive
 

Viewers also liked

Viewers also liked (20)

IBM Connect 2017: Your Data In the Major Leagues: A Practical Guide to REST S...
IBM Connect 2017: Your Data In the Major Leagues: A Practical Guide to REST S...IBM Connect 2017: Your Data In the Major Leagues: A Practical Guide to REST S...
IBM Connect 2017: Your Data In the Major Leagues: A Practical Guide to REST S...
 
ICONUK 2015: How to Embrace Your XPages Plugin Super Powers
ICONUK 2015: How to Embrace Your XPages Plugin Super PowersICONUK 2015: How to Embrace Your XPages Plugin Super Powers
ICONUK 2015: How to Embrace Your XPages Plugin Super Powers
 
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!
 
IBM Connect 2017: Back from the Dead: When Bad Code Kills a Good Server
IBM Connect 2017: Back from the Dead: When Bad Code Kills a Good ServerIBM Connect 2017: Back from the Dead: When Bad Code Kills a Good Server
IBM Connect 2017: Back from the Dead: When Bad Code Kills a Good Server
 
Show110 | Using the XPages Extension Library for the Real World
Show110 | Using the XPages Extension Library for the Real WorldShow110 | Using the XPages Extension Library for the Real World
Show110 | Using the XPages Extension Library for the Real World
 
ICONUK 2016: Back From the Dead: How Bad Code Kills a Good Server
ICONUK 2016: Back From the Dead: How Bad Code Kills a Good ServerICONUK 2016: Back From the Dead: How Bad Code Kills a Good Server
ICONUK 2016: Back From the Dead: How Bad Code Kills a Good Server
 
Engage 2016: Back From the Dead: How Bad Code Kills a Good Server
Engage 2016: Back From the Dead: How Bad Code Kills a Good ServerEngage 2016: Back From the Dead: How Bad Code Kills a Good Server
Engage 2016: Back From the Dead: How Bad Code Kills a Good Server
 
Angular.js in XPages
Angular.js in XPagesAngular.js in XPages
Angular.js in XPages
 
Lotus Notes: Live Long and Prosper
Lotus Notes: Live Long and ProsperLotus Notes: Live Long and Prosper
Lotus Notes: Live Long and Prosper
 
Optimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best PracticesOptimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best Practices
 
DEV-1430 IBM Connections Integration
DEV-1430 IBM Connections IntegrationDEV-1430 IBM Connections Integration
DEV-1430 IBM Connections Integration
 
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing Smartcloud
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing SmartcloudConnect 2017 DEV-1420 - Blue Mix and Domino – Complementing Smartcloud
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing Smartcloud
 
Beyond XPages
Beyond XPagesBeyond XPages
Beyond XPages
 
DEV-1467 - Darwino
DEV-1467 - DarwinoDEV-1467 - Darwino
DEV-1467 - Darwino
 
IBM Connect 2017: Refresh and Extend IBM Domino Applications
IBM Connect 2017: Refresh and Extend IBM Domino ApplicationsIBM Connect 2017: Refresh and Extend IBM Domino Applications
IBM Connect 2017: Refresh and Extend IBM Domino Applications
 
IBM Presents the IBM Notes and Domino Roadmap
IBM Presents the IBM Notes and Domino RoadmapIBM Presents the IBM Notes and Domino Roadmap
IBM Presents the IBM Notes and Domino Roadmap
 
OpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentOpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino Development
 
BP 308 - The Journey to Becoming a Social Application Developer
BP 308 - The Journey to Becoming a Social Application DeveloperBP 308 - The Journey to Becoming a Social Application Developer
BP 308 - The Journey to Becoming a Social Application Developer
 
BP207 - Meet the Java Application Server You Already Own – IBM Domino
BP207 - Meet the Java Application Server You Already Own – IBM DominoBP207 - Meet the Java Application Server You Already Own – IBM Domino
BP207 - Meet the Java Application Server You Already Own – IBM Domino
 
ICONUK 2013 - An XPager's Guide to Process Server-Side Jobs on IBM® Domino®
ICONUK 2013 - An XPager's Guide to Process Server-Side Jobs on IBM® Domino®ICONUK 2013 - An XPager's Guide to Process Server-Side Jobs on IBM® Domino®
ICONUK 2013 - An XPager's Guide to Process Server-Side Jobs on IBM® Domino®
 

Similar to Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!

Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
Ganesh Kondal
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 

Similar to Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU! (20)

Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf
 
Life in the Fast Lane: Full Speed XPages!, #dd13
Life in the Fast Lane: Full Speed XPages!, #dd13Life in the Fast Lane: Full Speed XPages!, #dd13
Life in the Fast Lane: Full Speed XPages!, #dd13
 
jQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPagesjQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPages
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
Ad111
Ad111Ad111
Ad111
 
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
 
CS101- Introduction to Computing- Lecture 32
CS101- Introduction to Computing- Lecture 32CS101- Introduction to Computing- Lecture 32
CS101- Introduction to Computing- Lecture 32
 
javascript Event Handling and introduction to event.ppt
javascript Event Handling and introduction to event.pptjavascript Event Handling and introduction to event.ppt
javascript Event Handling and introduction to event.ppt
 
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 
Event Programming JavaScript
Event Programming JavaScriptEvent Programming JavaScript
Event Programming JavaScript
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 
La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!
 
Developing high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerDeveloping high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web worker
 
Javascript why what and how
Javascript why what and howJavascript why what and how
Javascript why what and how
 

Recently uploaded

JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 

Recently uploaded (20)

AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
How To Build a Successful SaaS Design.pdf
How To Build a Successful SaaS Design.pdfHow To Build a Successful SaaS Design.pdf
How To Build a Successful SaaS Design.pdf
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with StrimziStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 

Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!

  • 1. 10 Mistakes You and Every XPages Developer Make (Yes, I said YOU!) Serdar Başeğmez (@sbasegmez) Developi Information Systems 1#engageug
  • 2. Serdar Başeğmez • IBM Champion (2011-2015) • Developi Information Systems, Istanbul • Contributing… • OpenNTF / LUGTR / LotusNotus.com • Featured on… • The View, NotesIn9 • Presented at… • IBM Connect and LUGs • Also… • Blogger and Podcaster on Scientific Skepticism 2#engageug
  • 3. Today • Why are we here? • Revisiting some key concepts • Browser-Server interaction • Repeat Control • Custom Controls • Dialogs • Managed Beans • Java 3#engageug
  • 4. This Session is About… • Problems of XPages developers. • Some from personal experience • Workshops, conversations, other XPages apps, etc. • Some from Stackoverflow… • Downloaded all Stackoverflow Q&A on #XPages tag. • Filtered code, applied some linguistic magic • Analyzed the most common word couples used together (NGram Analysis). 4#engageug
  • 5. What Topics Asked in Stackoverflow… 5#engageug The most common keywords in all questions from StackOverflow…
  • 6. It’s XPages… not xpages or Xpages or xPages  6#engageug
  • 7. Component Tree, View and Page States revisiting some key concepts 7#engageug
  • 8. 8#engageug Root Component (Global «view» variable) Collects all JavaScript imports used throughout the page. Automatically added by default… Some components does not inject all children initially Event Handlers are components too
  • 10. Components and Component Tree • Every Component is Java magic… • Component is a Java Object. • Generally, it has a different renderer. • Sometimes it has other helper classes. • Component Tree is an hierarchical representation • ‘Prepared’ during page load, ‘Revised’ between JSF phases. 10#engageug
  • 11. 11#engageug Old Component State: Display documents 1 to 30 New Component State: Display documents 31 to 60
  • 12. Page State • A page has a lifecycle in the server. • Persists its state as a component tree • Component tree also contains viewScope • Page State is stored on Disk or Memory • Disk: Good for Scalability • Memory: Good for Performance • Only the current page in memory: Optimized • One page per each user kept in memory. 12#engageug
  • 13. XPages Stateful Architecture 13#engageug XPages State Manager request response XPages ApplicationBrowser NSF DATA read/write previous state save state Each request contributes into a previous state…
  • 14. JSF Lifecycle what happens under the cover? 14#engageug
  • 15. Full Request – Response Lifecycle 15#engageug Restore View Apply Request Values Process Validations Update Model Values Invoke Application Render Response Process Events Process Events Process Events Process Events Request Response Response Complete Response Complete Response Complete Response Complete Validation/Conversion Errors Conversion Errors Do not update/validate (immediate)
  • 16. Full Request – Response Lifecycle 16#engageug Prepare Page Render Response beforePageLoad Request Response afterPageLoad First Time Page Load
  • 17. GET Requests – Lifecycle 17#engageug Restore View Render Response GET Request Response SKIP ALL PHASES
  • 18. Immediate Lifecycle 18#engageug Restore View Apply Request Values Render Response Process Events Request Response Response Complete Do not update/validate (immediate) SKIP SOME PHASES No update for model (e.g. Domino Document)
  • 19. Lifecycle for Validation Error 19#engageug Restore View Apply Request Values Process Validations Render Response Process Events Process Events Request Response Response Complete Response Complete Response Complete Response Complete Validation/Conversion Errors SKIP UPDATE VALUES No data written into the model (e.g. Domino Document)
  • 20. Why Lifecycle is so Important… • Performance, scalability, etc. • Between phases, dynamic values are computed many times • Combine Lifecycles and Partial Execute model • Don’t underestimate the load of hundreds of users. • If no need for any update, use immediate. • If no need for any validation, skip validation. • More information on links… • Troubleshooting very simple problems! • Validation/Update issues during Partial Refresh • e.g. when you use .getValue() or .getSubmittedValue()? #engageug
  • 21. Dynamic or not: #{…} vs. ${…} • #{…} bindings run whenever time they needed • Once at start, once between almost all phases! • Root causes of many performance issues. • Large view lookups for a combobox selection list? • ${…} bindings run when the page is loaded • At the time XSP prepares the page tree. • Once in the entire lifecycle of the page. • Mandatory for some attributes (e.g. «loaded»). 21#engageug
  • 22. "rendered" vs. "loaded" 22#engageug <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom"> <xp:label value="Here is a Hidden CC:" id="label1"> </xp:label> <xc:ccBasic rendered="#{javascript:return false;}"> </xc:ccBasic> <xc:ccBasic loaded="${javascript:return false;}"> </xc:ccBasic> </xp:view> When a CC included into the tree, ${…} bindings and page events will be evaluated! XSP ignores this CC…
  • 23. XPages Scopes Scope Validity Deletion Application Global* (* Except local XPiNC apps) Idle timeout of the app. (xsp.application.timeout – 30 mins) Session Per browser session Idle timeout of the session (**) (xsp.session.timeout – 30 mins) View Entire lifecycle of pages Limited number of Pages per user (Disk: xsp.persistence.file.maxviews – 16) (Mem: xsp.persistence.tree.maxviews – 4) Request A single request After Response Complete 23#engageug Application and Session scopes consume JVM memory… Cache wisely!
  • 24. XPages Scopes • SessionScope is a Browser session • It’s not related to authentication. Just a cookie… • Same user from different browser = Different Session • When you close the browser, you lose the session access. • If you logoff, things get complicated! • If anonymous access enabled, sessionScope cleared. • If another user logs in, sessionScope persists! • A big issue while testing the code with different users. • All Scopes are defined per NSF application… • One application cannot access scopes of another! • NSF application is where your XPages code runs. 24#engageug
  • 25. Browser – Server Interaction two sides of the same coin 25#engageug
  • 26. Browser – Server Interaction • Understanding the XSP object… • CSJS API for browser-server interaction • Provides basic AJAX functionality • Checks preconditions, errors and timeouts, Aggregates necessary header and POST content, Guarantees only one AJAX request at a time, • Widgets extend XSP for additional functionality • e.g. dialog adds openDialog(…) and closeDialog(…) • Event Handlers attach JavaScript to components 26#engageug
  • 27. 27#engageug Server Zone Client Zone XSP Manager Components Renderers Push HTML + CSJS Plugins UI Objects (DOM) Buttons, inputs, etc. XSP Object User Actions / Events FacesServlet AJAX Request GET/POST Build a New State
  • 28. <xe:dialog/> a potential code-breaker in wrong hands… 28#engageug
  • 29. The heir of the Dojo Dialog • Ext.Lib. Dialog is an extended Dojo Dialog… • Dojo Dialog is incompatible to the XPages. • Dojo injects the dialog out of the <form> tag. • From XPages standpoint, this is a problem. • So Ext.Lib uses a custom interaction mechanism for dialogs. • Dialog Component as an Example • Open/Close dialogs from SSJS or CSJS??? • Let’s zoom at what’s going on with the Dialog… 29#engageug
  • 30. A Basic Page with a Dialog 30#engageug XSP.openDialog("#{id:myDialog}") XSP.closeDialog("#{id:myDialog}", "#{id:myForm}") <script type="text/javascript"> function view__id1__id13_clientSide_onclick(thisEvent) { XSP.openDialog("view:_id1:myDialog") } XSP.addOnLoad(function() { XSP.attachEvent("view:_id1:_id13", "view:_id1:button1", "onclick", view__id1__id13_clientSide_onclick, false, 2); }); </script>
  • 31. Showing Dialog via CSJS 31#engageug Where is the value??? • XSP.openDialog() sends a GET request • The dialog prepares the contents • The response is added to the DOM.
  • 32. Common Issues with Dialogs • When we open a dialog from CSJS… • XSP.openDialog() sends a GET request to the server • The dialog prepares the contents and sends back. • The result is added to the DOM. • It DOES NOT submit any value to the server… • Server is not aware of any changes in other field values. • Almost the same when you close the dialog… • XSP.closeDialog(dialogId, refreshId): Closes the dialog and partially refresh a component. No POST request! • Use SSJS if you need to submit values… 32#engageug
  • 33. Common Issues with Dialogs • Using SSJS to open/close dialogs 33#engageug <xp:button value="Open Dialog SSJS" id="button3"> <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="button3"> <!– It should refresh something! --> <xp:this.action><![CDATA[#{javascript: getComponent("myDialog").show() }]]></xp:this.action> </xp:eventHandler> </xp:button> <xp:button value="SSJS Close" id="button4"> <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="myForm"> <!– We refresh the form so it reflects changes --> <xp:this.action><![CDATA[#{javascript: getComponent("myDialog").hide() }]]></xp:this.action> </xp:eventHandler> </xp:button>
  • 34. Common Issues with Dialogs • If you really need to use CSJS… • You can initiate a POST request first. 34#engageug <xp:button value="Open Dialog CSJS" id="button1"> <xp:eventHandler event="onclick" submit="false"> <xp:this.script><![CDATA[ XSP.partialRefreshPost("@none", { "onComplete": function() { XSP.openDialog("#{id:myDialog}"); } }); ]]></xp:this.script> </xp:eventHandler> </xp:button> • Submit a POST request • Refresh no element (refresh needed on close) • When you’re done, launch my dialog… • Attention: It took two AJAX requests!
  • 35. Common Issues with Dialogs • Need a single value? Here is a trick… • You can provide parameters to the dialog on CSJS… • XSP.openDialog(dialogId, dialogOptions, dialogParams) 35#engageug <xp:button value="Open Dialog" id="button1"> <xp:eventHandler event="onclick" submit="false"> <xp:this.script><![CDATA[ XSP.openDialog( "#{id:myDialog}", /* dialogId */ {}, /* options */ {"tab" : "tab1" } /* params */ ); ]]></xp:this.script> </xp:eventHandler> </xp:button> Adds a query string parameter to the GET request… (…) <xp:tabbedPanel id="tabbedPanel1" selectedTab="#{param.tab}"> (…) We can use it within the dialog…
  • 36. <xp:repeat/> what’s wrong with this mysterious component? 36#engageug
  • 37. The Basics of <xp:repeat/> • Repeat component iterates its child components • «value» attributes should be an iterable component (collection, array, list, etc.) • «first» and «rows» attributes for the start index and count. • It can be binded to any pager component. • Renders "header" and "footer" facets. • Repeat has two modes • DataIterator mode (default) • Repeat mode (when «repeatControls="true"») 37#engageug
  • 38. <xp:repeat id="repeat2" var="value" repeatControls="true" value="#{repeatValues}"> <xp:this.facets> <xp:label xp:key="header" value="START:" /> <xp:label xp:key="footer" value=":END" /> </xp:this.facets> <xp:image id="image2" url="#{value}" /> </xp:repeat> Two Modes of <xp:repeat/> 38#engageug <xp:repeat id="repeat1" var="value" value="#{repeatValues}"> <xp:this.facets> <xp:label xp:key="header" value="START:" /> <xp:label xp:key="footer" value=":END" /> </xp:this.facets> <xp:image id="image1" url="#{value}" /> </xp:repeat> Does not inject new components. Only one set of child components, render multiple times Injects multiple containers for every iteration.
  • 39. Implications of «repeatControls» • Child component limitations in DataIterator mode: • ${…} bindings will be processed only once. • ${…} bindings cannot consume repeat variables. • ${value} will be ignored. • ${javascript:value} will throw error. • Repeat mode: • Provides computed id’s for iterated fields (e.g. Radio) • Iterated columns for Data Tables • Limitation: Child elements are fixed, can’t be changed later. 39#engageug
  • 40. <xc:customControls/> do you miss subforms? 40#engageug
  • 41. Custom Controls • Specific to XPages… • IBM’s implementation of JSF Composite Components. • Similar to Subforms (but much better!) • Injects XPages into your XPages… • Custom Controls are XPages… • Reusable components with their own xsp-config files. • They support parameters, designer extensions, etc. 41#engageug
  • 42. ‘Multiple Choice’ Custom Controls • Among multiple CCs, one will be displayed. • If you can decide before loading page… • URL parameter, user role, data source, etc. • Static «loaded» can be used… • Want to switch during run-time? • According to an input, based on a dynamic value, etc. • Dynamic «rendered» values preferred mostly. • BUT, as shown before, this will evaluate the CC! • All ${…} bindings and pageLoad events 42#engageug
  • 43. A Better Approach: <xe:dynamicContent> 43#engageug <xe:dynamicContent id="dynamicContent1" defaultFacet="cc01"> <xp:this.facets> <xc:ccBasic xp:key="cc01" id="myCC_01"></xc:ccBasic> <xc:ccBasic xp:key="cc02" id="myCC_02"></xc:ccBasic> </xp:this.facets> </xe:dynamicContent> After switching… <xp:button value="Switch Dynamic Content" id="button1"> <xp:eventHandler event="onclick" submit="true" refreshMode="complete"> <xp:this.action> <xe:changeDynamicContentAction for="dynamicContent1" facetName="cc02"> </xe:changeDynamicContentAction> </xp:this.action> </xp:eventHandler> </xp:button>
  • 44. Common Issues for Custom Controls • Black box approach with Custom Properties… • Prioritize Reusability. • Do not hardcode ‘things’ inside your custom control… • Parent XPage – Custom Control interactions • Interact to the data sources or components from the parent XPage • Trigger an event from the parent XPage? 44#engageug
  • 45. 45#engageug <xp:inputText id="inputText1" value="#{compositeData.dataSource[compositeData.fieldName]}"> <xp:eventHandler event="onchange“ submit="true" refreshMode="partial“ refreshId="#{compositeData.onChangeRefreshId}"> <xp:this.action><![CDATA[#{javascript: var handler = compositeData.onChange; if(null!=handler && typeof(handler)=='com.ibm.xsp.actions.ExecuteScriptAction') { handler.setParamNames(['value']); handler.invoke(facesContext, [this.getParent().getValue()]); } }]]></xp:this.action> </xp:eventHandler> </xp:inputText> A Custom Control Reuses an inputText for a special purpose
  • 47. Managed Beans - approaching to the Java zone - 47#engageug
  • 48. Managed Beans - Basics • JavaBean is a simple Java class… • Empty constructor, Serializable • Has Getter and Setter methods to access its private fields • Managed Bean is a JavaBean that is managed. • It has a name and scope definition. • The platform is responsible of the lifecycle. • They are created on their first use… • Single Instance guaranteed, but not Thread-safe! • Managed Beans should be Serializable! • It’s a MUST for the View Scope • Best Practice in General! 48#engageug
  • 49. Common Issues with Managed Beans • Error handling in Constructor… • Managed beans are instantiated via Reflection (long story). • If constructor fails, it throws meaningless errors. • No stack trace for constructor exceptions! • USE a proper try-catch block in your constructor. • It’s important to provide an informative message. • Have an error page and/or logging mechanism… 49#engageug public Bean01() { Database myDb = ExtLibUtil.getCurrentDatabase(); try { View myView = myDb.getView("Test01"); Document myDoc = myView.getDocumentByKey("key"); // ... do stuff } catch (NotesException e) { e.printStackTrace(); } } javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'demo.Bean01'.. java.lang.ClassNotFoundException: class java.lang.NullPointerException: null
  • 50. Common Issues with Managed Beans 50#engageug public class Bean01 implements Serializable { private static final long serialVersionUID = 1L; private long timeCreated; private ApplicationSetupBean appSetup; private DocumentCollection cachedDocs; private transient Database myDb; public Bean01() { // Stuff } // Some other stuff } Do not store other beans! Never Store Domino Objects! Transient is also a bad idea!
  • 51. Common Issues with Managed Beans • «Do-not-store-these» within managed beans. • Never store ANY Domino objects! • Domino objects has C-handles on back-end. They will be recycled after each request-response cycle. • Only for view-scoped beans, you can define transient fields but it’s a bad habit! • Always store the reference (UniqueId, dbPath, etc.) • Never store another bean or static Java object. • During lifecycle or design-change objects might be reconstructed. • Many of these objects are cheap to reproduce! 51#engageug
  • 52. Common Issues with Managed Beans • Memory usage concerns are frequently asked. • Especially important for caching beans… • Application and session scope beans live in the memory • View scope beans are stored in either memory or disk • It depends on the persistence setting. • Request scope is short-lived. • Cost-benefit analysis for using memory vs. time • Caching more information needs more memory. • Not caching anything is processing time and I/O activity • Get creative  52#engageug
  • 53. Use of Java welcome to the magical world 53#engageug
  • 54. Latin Small Letter Dotless-i • “.toLowerCase()” and “.toUpperCase()” • “DOMINO”.toLowerCase() = “domıno” on my server!!! • Use Locale parameter… e.g. “.toLowerCase(Locale.US)” • There are millions of computers with Turkish locale!  54#engageug Don’t kill me… i  İ I  ı
  • 55. 55#engageug For this section… If you use OpenNTF Domino API… Smile towards others
  • 56. Common Issues with Java • Recycle… Recycle… Recycle… • Domino objects keep a backend C-handle. It’s limited! • Recycle every Domino objects you have used, • …except Session and the current database… • Recycle in «finally {…}» section. • Also recycle in SSJS. • Tired of recycling? • Use OpenNTF Domino API… 56#engageug Remember, there is a great team behind the Project. …and they will be thirsty tonight 
  • 58. Books • Mastering XPages 2nd Edition http://www.redbooks.ibm.com/Redbooks.nsf/ibmpressisbn/9780133373370?Open • XPages Portable Command Guide http://www.redbooks.ibm.com/Redbooks.nsf/ibmpressisbn/9780132943055?Open • XPages Extension Library http://www.redbooks.ibm.com/Redbooks.nsf/ibmpressisbn/9780132901819?Open 58#engageug
  • 59. XPages Request Process Lifecycle (X-RPL) • Blog Series: Understanding Partial Execution, Paul S. Withers • Part One – Refresh http://www.intec.co.uk/understanding-partial-execution-part-one-refresh/ • Part Two – Execution http://www.intec.co.uk/understanding-partial-execution-part-two-execution/ • Part Three – JSF Lifecycle http://www.intec.co.uk/understanding-partial-execution-part-three-jsf-lifecycle/ • Also check these XSnippets by Tony McGuckin: • XPages Request Processing Lifecycle explorer code http://openntf.org/XSnippets.nsf/snippet.xsp?id=xpages-request-processing-lifecycle-explorer-code... • dynamicContent - Efficient loading/rendering of a Component Tree http://openntf.org/XSnippets.nsf/snippet.xsp?id=dynamiccontent-efficient-loadingrendering-of-a-component-tree 59#engageug
  • 60. Performance and Scalability • IBM ConnectED 2015 - MAS103 XPages Performance and Scalability, Paul S. Withers & Tony McGuckin http://www.slideshare.net/paulswithers1/mas103-xpages-performance-and-scalability • XPages Performance: pro tips, Nathan T. Freeman https://nathantfreeman.wordpress.com/2013/04/12/xpages-performance-pro-tips • BLUG 2013: Life In The Fast Lane: Full Speed XPages, Ulrich Krause http://www.slideshare.net/eknori/blug-2013final • XPages Tip: Realizing the Cost of a Value Binding, Serdar Basegmez http://lotusnotus.com/lotusnotus_en.nsf/dx/xpages-tip-realizing-the-cost-of-a-value-binding....htm 60#engageug
  • 61. Miscellaneous • IAmLug 2013: Managed Beans: When, Why and How, Russel Maher http://www.slideshare.net/RussellMaher/managed-beans-when-why-and-how • Tim Explains: SSJS Object Persistence, David Leedy http://www.notesin9.com/2014/05/20/tim-explains-ssjs-object-persistence/ • Meet the XSP object, Stephan H. Wissel http://www.wissel.net/blog/d6plinks/SHWL-878B9D • Stackoverflow Answer to "What is the best way to recycle Domino objects in Java Beans", Tim Tripcony http://stackoverflow.com/a/11160925/1167922 • Stackoverflow Answer to "recycle domino objects after they are lost", Paul S. Withers http://stackoverflow.com/a/28827606/1167922 61#engageug
  • 62. Miscellaneous • Accessing the Value of Components within a Repeat Control from Outside, Brad Balassaitis http://xcellerant.net/2013/07/29/access-repeat-components-from-outside • Why it is important to use the Recycle() method on every Java object http://www-01.ibm.com/support/docview.wss?uid=swg21097861 • Sessions, logout, sessionScope and userScope, Paul S. Withers http://http://www.intec.co.uk/sessions-logout-sessionscope-and-userscope/ • "Dotless i", toLowerCase and toUpperCase functions: Use responsibly!, Serdar Basegmez http://lotusnotus.com/lotusnotus_en.nsf/dx/dotless-i-tolowercase-and-touppercase-functions-use- responsibly.htm 62#engageug
  • 63. The End ask questions now get social later @sbasegmez 63#engageug