AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XPages
1. "Marty, You're Just Not Thinking Fourth
Dimensionally": Troubleshooting XPages
Paul Withers / 2nd Feb 2016
2. Acknowledgements and Disclaimers
Availability. References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM
operates.
The workshops, sessions and materials have been prepared by IBM or the session speakers and reflect their own views. They are provided for informational
purposes only, and are neither intended to, nor shall have the effect of being, legal or other guidance or advice to any participant. While efforts were made to
verify the completeness and accuracy of the information contained in this presentation, it is provided AS-IS without warranty of any kind, express or implied. IBM
shall not be responsible for any damages arising out of the use of, or otherwise related to, this presentation or any other materials. Nothing contained in this
presentation is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms
and conditions of the applicable license agreement governing the use of IBM software.
All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved.
Actual environmental costs and performance characteristics may vary by customer. Nothing contained in these materials is intended to, nor shall have the effect
of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results.
Š Copyright IBM Corporation 2015. All rights reserved.
⢠U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
⢠IBM, the IBM logo, ibm.com, and IBM Domino are trademarks or registered trademarks of International Business Machines Corporation in the United States,
other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol (ÂŽ or â˘),
these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be
registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at âCopyright and trademark informationâ at
www.ibm.com/legal/copytrade.shtml
3. About Me
âMy name is Darth Vader. I
am an extraterrestrial from
the planet Vulcanâ
4. Why This Session?
⢠XPages often doesnât work âas expectedâ
ď§ Custom Control -> XPage -> Browser
ď§ Browser -> Server -> Browser
ď§ SSJS / CSJS
ď§ State management
ď§ Partial Refresh
⢠Lots of StackOverflow questions
ď§ Which wouldnât be referenced here unless many developers hit
the same issues!
5. Agenda
⢠Buzz-Quote Bingo!
⢠Twin Pines Mall / Lone Pine Mall
⢠Martyâs Family Photo
⢠Marty McFly and the Tannens
⢠Power of Love
⢠Alternate 1985
⢠Indians!
⢠Itâs Erased!
9. 1. Retrieve/Create Code in documentId
⢠ALWAYS use ${âŚ} when calculating properties like
documentId
⢠Otherwise calculated FOUR times on page load
ď§ If attached to a Panel, TWICE AFTER beforePageLoad
ď§ If attached to XPage, TWICE BEFORE beforePageLoad
⢠Canât use scoped variables set in beforePageLoad!
ď§ Always TWICE DURING render response
10. 1a. Timing of Initialisations
⢠viewScoped variables canât be set before PAGE LOAD
ď§ Controller frameworks put variable in requestScope and move to
viewScope
⢠data, dataContexts etc
ď§ attached to XPage / Custom Control - initialised alongside
component
ď§ Attached to Panel â initialised during PAGE LOAD
11. 2. ignoreRequestParams
⢠ALWAYS use ignoreRequestParams where appropriate
ď§ If no params, computed settings respected
ď§ If params passed, computed settings overwritten
12. 3. Submit Button Type
⢠DONâT use save=âtrueâ (âSubmitâ button type)
ď§ Use script, not simple actions
⢠Greater control, less risk
⢠You save only what should be saved
⢠Preparing you for Java / beans / beyond
⢠Form with single rich text field can cause problems even with
script
15. 4. Keep Pages In Memory
⢠XPages is stateful
⢠Number of component trees restricted for performance
⢠Dumped xsp.session.timeout minutes after browser closed
ď§ Browser doesnât tell server session is no longer used!
17. 6. Explanation of ânostateâ
⢠DataView and nostate
ď§ Toggle expand/collapse is fine
ď§ Navigating to specific pages is fine
ď§ Next / Previous is relative to defaults
ď§ Toggle detail is relative to defaults
⢠Unless detailsOnClient=âtrueâ
⢠Details pushed to browser along with rest of content
⢠âToggleâ is client-side show/hide
20. 7. Repeat Controls and Component Tree
⢠Only one set of components in component tree
⢠repeatControls=âtrueâ changes behaviour
ď§ x many sets of components
ď§ Hard-wired to specific entries at page load
ď§ Pagers have no effect because of hard-wiring
ď§ Allows âloadedâ computations within the repeat, e.g. idâs
⢠Cannot compute repeatControls=âtrueâ within compositeData
21. 8. Dynamic Content Control
⢠Only components from current facet exist in component tree
⢠Component tree dynamically updated
⢠Better than showing / hiding via rendered property
22. 9. Custom Controls and Scope
⢠Custom control is inserted into component tree
⢠Variable names outside custom control available
⢠As long as same variable used, no need to pass
⢠Same rules as for any component
ď§ Is variable available by navigating upwards in tree?
ď§ Cannot retrieve variables from another branch
⢠E.g. different repeat entry, repeat entry from outside repeat
24. ControllingViewHandler
⢠Creates component tree for specific XPage
⢠Runs before beforePageLoad event
⢠super.createView() loads component tree
⢠Also creates viewScope
ď§ Not available before call to super.createView()
ď§ Load variables to requestScope before super.createView()
ď§ Move to viewScope after super.createView()
30. 10. Understanding Partial Refresh
⢠1. RESTORE VIEW
ď§ Get component tree again
⢠2. APPLY REQUEST VALUES
ď§ Pass String values from browser to executed component tree
⢠3. PROCESS VALIDATIONS
ď§ Run validators AND converters for executed component tree
31. 10. Understanding Partial Refresh
⢠4. UPDATE MODEL VALUES
ď§ Convert string values and update executed component tree
⢠5. INVOKE APPLICATION
ď§ Run application logic (SSJS / Java)
⢠6. RENDER RESPONSE
ď§ Update HTML for executed component tree and post refresh area
32. 11. Conditionally Hidden Save Button
⢠Set rendered property on button
ď§ For best practice, use view.isRenderingPhase()
ď§ Ensure set to true for other phases or code will not run
⢠Add partial refresh where appropriate
ď§ Ensure refresh area correct or button will not show
ď§ Ensure disableValidators=âtrueâ or button will not hide again if
invalid
33. 12. Reasons Code May Not Work!
⢠CSJS returning false â check Firebug for POST event
⢠Conversion error â 1,2,3,6
⢠Validation error â 1,2,3,6
⢠Exec id not including components being used by application
logic
⢠Exec id not including component triggering application logic
⢠Event handler not rendered in phase 4
⢠Refresh area not including errors control
34. 13. Troubleshooting
⢠Use PhaseListener
⢠java.util.logging.ConsoleHandler.level manages console
logging of server validation errors, since 8.5.3
ď§ In workspace.configrcpinstall.properties
⢠ALWAYS including errors control in refresh area
⢠Be conscious of rendered property
35. BONUS 1: Data View
⢠dataCache=âidâ setting available on View datasource
⢠Better for performance, only caches id, not full ViewEntry
(wrapped)
⢠âvarâ not available during Apply Request Values
ď§ Compute value only in Render Response
36. BONUS 2 - Dialog
⢠To refresh area,
getComponent(âdialog1â).hide(âmyRefreshAreaâ)
ď§ POST
⢠Run SSJS
⢠view.postScript - XSP.closeDialog
ď§ GET
⢠Refresh myRefreshArea
42. 15. âResp is nullâ
⢠Understand page load and dynamically
ď§ âresp is nullâ â options for picker are not available
ď§ Picker is client-side, but values are passed to renderer server-
side
43. 16. SSJS in CSJS
⢠SSJS in CSJS
ď§ Computed server-side as part of script renderer
ď§ Only re-computed by partial refresh
⢠To access component values
ď§ Use dojo.byId or variants to access client-side element
ď§ Trigger partial refresh to update SSJS embedded into CSJS
46. 17. Domino Objects in Scopes
⢠Domino objects canât be stored in scopes.
ď§ DateTimes are the most common culprit
ď§ Use .toJavaDate() to store Java Date
⢠Similar issues with SSJS functions stored in variables
47. 18. Impact of Persistence Setting
⢠For Domino objects in scopes, depending on persistence
setting
ď§ Keep pages in memory â value just lost
ď§ Keep pages on disk â error thrown to server, redirect to error
page (fails to display)
ď§ Keep current page in memory â value just lost, error 500 on
navigating
49. Summary
⢠Understand scope and custom controls
⢠Understand partial refresh is more than just âpartial
refreshâ
⢠Understand SSJS is computed and injected into CSJS
⢠Use Firebug or comparable tool
⢠Donât store Domino objects in scopes
⢠Understand impact of serialization
50. Thank You!
Paul Withers
Intec Systems Ltd
IBM Champion
OpenNTF Board Member
@paulswithers
pwithers@intec.co.uk
http://www.intec.co.uk/blog