The Eureka Moment:XPages Under The Covers        Paul Withers   Intec Systems Limited
AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – Per...
About MeSenior Domino Developer, Intec Systems LtdXPages Developer since 8.5.0IBM ChampionCo-Host of The XCastCo-Author of...
Why This Session?Nothing in life is to be feared, it is only to be understood. Now  is the time to understand more, so tha...
Why This Session?XPages vs Domino HTTPLanguage Performance  Language Roadmap and JustificationPersistence options  Which s...
ExpectationsYou should:  Know what XPages are  Know that XPages runs on a Domino Server  Know the Computed Field, Edit Box...
To Download Sample AppSource code at http://projects.qtzar.com/projects/jsf_eurekaSource control with GitDownload and inst...
AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – Per...
Server Architecture  Java Virtual Machine XSP Command Manager  Domino HTTP Server
So When an XPage Is Served...Can HTTP Server resolve the URL?  HTTP 404 ErrorDoes user have access to NSF?  HTTP Authentic...
So When an XPage Is Served...Does the signer have access to run XPages?  HTTP 403 ErrorAre there SSJS errors?  XSP Command...
*HTTP Error 500 ReasonsNo server / custom error page definedMissing Extension Library or other library on serverjava.lang....
XPiNCServer-based NSFs need a local XSPCommand Manager etc.Authentication via Notes logon on local PCSigner access granted...
AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – Per...
Java Virtual Machine Means...Each NSF is a separate Java applicationsessionScope is per NSF  Browser session, NOT user ses...
DEMO
JAVA Virtual MachineXPages → Java classes → Java bytecodeEach control is a Java classExtensions are pre-packaged Java clas...
XPages Control LanguagesLiteral values  Strings, booleans etcExpression Language  #{document1.FirstName}SSJS  #{javascript...
HypothesesHow will fewer controls improve performance?How will different languages affect  performance?What is the compari...
DEMO
Performance of LanguagesThe fewer controls the better= less Java code to be runReason for Extension Library controls  Less...
AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – Per...
JSF and SerializationHTTP is state-lessJSF keeps state-full server representation of UI (component tree or view)Objects st...
Persistence Tab
Persistence optionsComponent tree (map of XPage on server) either held in memory of JVM or serialized to diskxsp.persisten...
Demo
Persistence SummaryKeep Pages in Memory  Remembering, remembering, rememberingKeep Pages on Disk  Writing...next? You want...
Persistence SummaryGzip Persisted Files  Writing   ...next? You want it again? ReadingPersist Files Asynchronously  Server...
General Tab
General optionsSettings available in xsp.properties editorApplication & Session timeouts  XSP Command Manager within HTTP ...
Demo
xsp.session.transientState not persisted  NOT “Go to next page” from current  INSTEAD “Go to next page” from default  NOT ...
AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – Per...
JSF LifeCycle
Six PhasesRestore View  JSF component tree retrievedApply Request Values  this.setSubmittedValue(passedValue) run  Any eve...
Six Phases ContinuedUpdate Model Values  this.setValue(this.getSubmittedValue());  this.setSubmittedValue(null)Invoke Appl...
AbstractPhaseListenerAbstract because it cant be instantiatedImplements javax.faces.event.PhaseListenerAllows us to track ...
DEMO
Basic ProcessingValidation fails beforeRestoreView afterRestoreView beforeApplyRequestValues afterApplyRequestValues befor...
No ValidationConversion still honoured If failed, skips from ProcessValidations to RenderResponse Event Logic not runIf no...
immediate=“true”Validation fails beforeRestoreView afterRestoreView beforeApplyRequestValues afterApplyRequestValues befor...
DIY SSJS ValidatorsRuns AFTER Apply Request ValuesRuns BEFORE Update Model Values  submittedValue property set  value prop...
DIY ValidatorRuns at same time as any other validatorUse xp:validator child of validators property of controlvalidatorId p...
DIY Validator – Java ClassUse Java class implementing Validator  javax.faces.validator.Validatorvalidate(FacesContext,UICo...
AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – Per...
Performance SmackdownCompute on Page Load (Loaded)Compute Dynamically (Runtime)ThemedataContexts  “Global variables”  Scop...
Performance SmackdownPage Load – how many callsPartial Refresh – how many callsexecMode=“partial”  Runs over only part of ...
DEMO
Smackdown ResultsLoaded makes fewer callsTheme cannot override loadedRuntime and theme makes same callsdataContext makes f...
AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – Per...
Bonus – Repeats RevisitedSee Bonus – Java Performance + Rendered  rendered property set for each of 50000 rowsSSJS in Scri...
SummaryScoped variables not cleared by ?logoutCombining controls improves performancePersistence options can optimise appl...
SummaryScript libraries work for application reusabilitydataContexts better for page reusabilityVariableResolver best for ...
Combining Controls Results
Language Lifecycle Results
Code Location Results
To Download Sample AppSource code at http://projects.qtzar.com/projects/jsf_eurekaSource control with GitDownload and inst...
Evals, Questions & Contact DetailsPaul Withersemail: pwithers@intec.co.uktwitter: @PaulSWithersskype: PaulSWithersblog: ht...
Eureka moment
Upcoming SlideShare
Loading in …5
×

Eureka moment

2,355 views
2,204 views

Published on

Extended version for DanNotes

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,355
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Human nature is to resist what is new because we don't understand it. Lots of new things going on behind scenes in XPages. This session will demystify some. Who has struggled with a problem for hours, then found one piece of information that would have given you the answer straight away, if you'd known it? That's the Eureka moment: one crucial piece of info that explains everything.
  • If you attended Intro to XPages session, you will be able to keep up with this session. If you didn't go because you knew it, you'll be able to keep up with this session. If you know what a VariableResolver is, how to code one, why you might need to change it in the future, go get a beer!
  • Traditional Domino web apps used HTTP server. Java servlets used JVM XPages uses both How? When?
  • HTTP 500 if fatal error with XPages runtime - memory issue - Extension Library used by app but not installed - Java class cannot be loaded (NoClassDefFoundError) - Other database compile issue
  • XPINC IS LOCAL EVEN IF NSF IS ON SERVER
  • Who wants a demo? NOTE SPECIFICALLY sessionScope.sessionID
  • Summary of demo
  • Based on previous slides, what will happen? If we split languages across controls, so controls with single language? If we combine literal values and A.N.Other language? If we use different languages?
  • Jump to Application Perspective – Package Explorer – Project Explorer Java code does the same as an Xagent - facesContext,getResponseWriter() - writer.write()
  • Based on previous slides, what will happen? If we split languages across controls, so controls with single language? If we combine literal values and A.N.Other language? If we use different languages?
  • Summary of demo
  • If you want to store / pass info between requests - Add to QueryString - Store in cookies - Pass in AJAX request in response JSF handles this – we've seen sessionID cookie and JSF sessionID in sessionScope. This ensures same session is used Recycle-safe, i.e. values are stored in Java beans and written back to the server as and when required. We'll come back tot hat later.
  • If you want to store / pass info between requests - Add to QueryString - Store in cookies - Pass in AJAX request in response JSF handles this – we've seen sessionID cookie and JSF sessionID in sessionScope. This ensures same session is used Recycle-safe, i.e. values are stored in Java beans and written back to the server as and when required. We'll come back tot hat later.
  • Screenshots of new Persistence tab of xsp.properties file Server Page Persistence – see demo Page Persistence Mode
  • If immediate = “true” and using component values, need to use getComponent(“myComponent”).getSubmittedValue()
  • If NOT using immediate = “true” and using component values, need to use getComponent(“myComponent”).getValue()
  • In the following demos, I'm using an AbstractPhaseListener to check what's happening where
  • Let's see what happens during page events
  • Summary of results of JSF Lifecycle - Basic
  • Summary of results of JSF Lifecycle – No Validation
  • Summary of results of JSF Lifecycle - Immediate
  • Let's see what happens depending on where Computed Field value property and Edit Box rendered property are defined
  • Summary of demo
  • Eureka moment

    1. 1. The Eureka Moment:XPages Under The Covers Paul Withers Intec Systems Limited
    2. 2. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – PerformanceRendered / Language Performance
    3. 3. About MeSenior Domino Developer, Intec Systems LtdXPages Developer since 8.5.0IBM ChampionCo-Host of The XCastCo-Author of XPages Extension Library book
    4. 4. Why This Session?Nothing in life is to be feared, it is only to be understood. Now is the time to understand more, so that we may fear less. Marie CurieA matter that becomes clear ceases to concern us. Friedrich NietzscheFurious activity is no substitute for understanding. H.H. WilliamsNo. I am your father. Darth Vader
    5. 5. Why This Session?XPages vs Domino HTTPLanguage Performance Language Roadmap and JustificationPersistence options Which setting for which applicationJSF Lifecycle – understand page processingPartial refresh – beyond event defaults
    6. 6. ExpectationsYou should: Know what XPages are Know that XPages runs on a Domino Server Know the Computed Field, Edit Box, Repeat controlsYou dont: Have a thorough understanding of JSF Have expert knowledge of dataContexts, managed beans, PhaseListeners and VariableResolvers
    7. 7. To Download Sample AppSource code at http://projects.qtzar.com/projects/jsf_eurekaSource control with GitDownload and install eGit from OpenNTFCreate new project from source code http://git.qtzar.com/jsf_eureka.git/Associate with new NSF
    8. 8. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – PerformanceRendered / Language Performance
    9. 9. Server Architecture Java Virtual Machine XSP Command Manager Domino HTTP Server
    10. 10. So When an XPage Is Served...Can HTTP Server resolve the URL? HTTP 404 ErrorDoes user have access to NSF? HTTP Authentication PageCan HTTP Server find resource in the NSF? HTTP 404 Error
    11. 11. So When an XPage Is Served...Does the signer have access to run XPages? HTTP 403 ErrorAre there SSJS errors? XSP Command Manager takes over HTTP 500 error*Return XPage
    12. 12. *HTTP Error 500 ReasonsNo server / custom error page definedMissing Extension Library or other library on serverjava.lang.NoClassDefFoundErrorjava.lang.securityException Check <domino>dataIBM_TECHNICAL_ SUPPORTxpages_exc_ServerName_yyyy_ MM_dd@hh_mm_ss.log
    13. 13. XPiNCServer-based NSFs need a local XSPCommand Manager etc.Authentication via Notes logon on local PCSigner access granted via ECL on local PCXPages Extensions, Java packages must bedeployed locallyLogging accessible from Help → Support →View Log on local PC
    14. 14. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – PerformanceRendered / Language Performance
    15. 15. Java Virtual Machine Means...Each NSF is a separate Java applicationsessionScope is per NSF Browser session, NOT user session Setting sessionScope in Db1.nsf does NOT set sessionScope in Db2.nsfsessionScope is ONLY within JVM – not cleared by HTTP logout
    16. 16. DEMO
    17. 17. JAVA Virtual MachineXPages → Java classes → Java bytecodeEach control is a Java classExtensions are pre-packaged Java classes Define properties (what can be customised) Define renderers (what is printed)SSJS code is String passed to Java methodJava code prints HTML to browser
    18. 18. XPages Control LanguagesLiteral values Strings, booleans etcExpression Language #{document1.FirstName}SSJS #{javascript:document1.getItemValueString(“FirstName”)}Custom All of the above
    19. 19. HypothesesHow will fewer controls improve performance?How will different languages affect performance?What is the comparison of standard Dojo vs Extension Library perform?
    20. 20. DEMO
    21. 21. Performance of LanguagesThe fewer controls the better= less Java code to be runReason for Extension Library controls Less Java code in XPages / Custom Controls Some controls lazy loadedCombining languages is goodEL is quicker than SSJS
    22. 22. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – PerformanceRendered / Language Performance
    23. 23. JSF and SerializationHTTP is state-lessJSF keeps state-full server representation of UI (component tree or view)Objects stored in component tree must be serializable (persist between requests) Domino objects recycled after each request Datasources are recycle-safe
    24. 24. Persistence Tab
    25. 25. Persistence optionsComponent tree (map of XPage on server) either held in memory of JVM or serialized to diskxsp.persistence.XXX propertiesSee persistence tab of new xsp.propertieseditorPackage Explorer → WebContentWEB-INFxsp.properties
    26. 26. Demo
    27. 27. Persistence SummaryKeep Pages in Memory Remembering, remembering, rememberingKeep Pages on Disk Writing...next? You want it again? ReadingKeep Only The Current Page In Memory Remembering, remembering, remembering Oh, new page? Writing...and now Remembering, remembering, remembering
    28. 28. Persistence SummaryGzip Persisted Files Writing ...next? You want it again? ReadingPersist Files Asynchronously Server busy, remembering. Next? (Writing, writing)Maximum Pages... Remembering, remembering, remembering Writing, retrieving, writing, writing
    29. 29. General Tab
    30. 30. General optionsSettings available in xsp.properties editorApplication & Session timeouts XSP Command Manager within HTTP server Session timeout overridden by HTTP session timeoutxsp.session.transient=“false” XPage becomes stateless Default VALUES overridden between requests Default STATES not overridden
    31. 31. Demo
    32. 32. xsp.session.transientState not persisted NOT “Go to next page” from current INSTEAD “Go to next page” from default NOT “Toggle show detail” from previous state INSTEAD “Toggle show detail” from defaultValues persistedGreat for large, read-only pages – no storageNeed to build your own “relative” functionality
    33. 33. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – PerformanceRendered / Language Performance
    34. 34. JSF LifeCycle
    35. 35. Six PhasesRestore View JSF component tree retrievedApply Request Values this.setSubmittedValue(passedValue) run Any event logic run if immediate=“true”Process Validation Any converters applied Any validators applied
    36. 36. Six Phases ContinuedUpdate Model Values this.setValue(this.getSubmittedValue()); this.setSubmittedValue(null)Invoke Application Any event logic runRender Response HTML rendered and state saved Only event that runs during page load
    37. 37. AbstractPhaseListenerAbstract because it cant be instantiatedImplements javax.faces.event.PhaseListenerAllows us to track JSF lifecycle phasesJava class plus reference in faces-config
    38. 38. DEMO
    39. 39. Basic ProcessingValidation fails beforeRestoreView afterRestoreView beforeApplyRequestValues afterApplyRequestValues beforeProcessValidations beforeRenderResponse afterRenderResponseEvent logic not run
    40. 40. No ValidationConversion still honoured If failed, skips from ProcessValidations to RenderResponse Event Logic not runIf no conversion errors, all phases runValues passed from submittedValue to valueComponent tree updated
    41. 41. immediate=“true”Validation fails beforeRestoreView afterRestoreView beforeApplyRequestValues afterApplyRequestValues beforeRenderResponse afterRenderResponseEvent logic run in ApplyRequestValues phaseComponent value never goes past submittedValueComponent tree not updated
    42. 42. DIY SSJS ValidatorsRuns AFTER Apply Request ValuesRuns BEFORE Update Model Values submittedValue property set value property still NULL (or last stored value)Use validator property of controlCheck getSubmittedValue()Post error with facesContext.addMessage()Abort with this.setValid(false)
    43. 43. DIY ValidatorRuns at same time as any other validatorUse xp:validator child of validators property of controlvalidatorId property maps to validator-id in faces-config.xmlvalidator-class maps to Java class
    44. 44. DIY Validator – Java ClassUse Java class implementing Validator javax.faces.validator.Validatorvalidate(FacesContext,UIComponent,Object) method performs validation, returns voidPost error using throw ValidatorExceptionThird argument is submittedValue – StringValidatorException takes FacesMessage javax.faces.application.FacesMessage
    45. 45. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – PerformanceRendered / Language Performance
    46. 46. Performance SmackdownCompute on Page Load (Loaded)Compute Dynamically (Runtime)ThemedataContexts “Global variables” Scoped to XPage, Custom Control, Panel Referenced via EL – #{var1}
    47. 47. Performance SmackdownPage Load – how many callsPartial Refresh – how many callsexecMode=“partial” Runs over only part of component tree
    48. 48. DEMO
    49. 49. Smackdown ResultsLoaded makes fewer callsTheme cannot override loadedRuntime and theme makes same callsdataContext makes fewer callsexecMode=“partial” improves performance IMPORTANT: Define id to execute lifecycle on EventHandler – All Properties
    50. 50. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event Model – LifecycleJSF Event Model – PerformanceRendered / Language Performance
    51. 51. Bonus – Repeats RevisitedSee Bonus – Java Performance + Rendered rendered property set for each of 50000 rowsSSJS in Script Library performs worstSL much worse on partial refreshVariableResolver best for performance Deprecated in JSF 2.0 for ELResolverDataContext next best (rendered property), but only reusable within page
    52. 52. SummaryScoped variables not cleared by ?logoutCombining controls improves performancePersistence options can optimise applicationJSF lifecycle affects event processingLoaded and dataContexts offer benefitsexecMode improves performance
    53. 53. SummaryScript libraries work for application reusabilitydataContexts better for page reusabilityVariableResolver best for application-levelreusabilityUpgrade VariableResolver to ELResolver whenXPages updated to JSF 2.0Use AbstractPhaseListener to test
    54. 54. Combining Controls Results
    55. 55. Language Lifecycle Results
    56. 56. Code Location Results
    57. 57. To Download Sample AppSource code at http://projects.qtzar.com/projects/jsf_eurekaSource control with GitDownload and install eGit from OpenNTFCreate new project from source codeAssociate with new NSF
    58. 58. Evals, Questions & Contact DetailsPaul Withersemail: pwithers@intec.co.uktwitter: @PaulSWithersskype: PaulSWithersblog: http://www.intec.co.uk/blogYouTube channel: http://www.youtube.com/intecsystemswebsite: http://www.intec.co.uk

    ×