Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Eureka moment

1,445 views

Published on

Presentation from BLUG 2012

Published in: Technology
  • Be the first to comment

Eureka moment

  1. 1. The Eureka Moment: The JSF Knowledge You Need To Understand XPages Paul Withers – Intec Systems Ltd
  2. 2. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event ModelSummary
  3. 3. About MeSenior Domino Developer, Intec Systems LtdXPages Developer since 8.5.0IBM ChampionCo-Host of The XCast
  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. 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
  6. 6. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event ModelSummary
  7. 7. Server Architecture Java Virtual Machine XSP Command Manager Domino HTTP Server
  8. 8. 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
  9. 9. 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 errorReturn XPage
  10. 10. XPiNCServer-based NSFs need a local XSP Command Manager etc.XPages Extensions, Java packages must be deployed locallyAuthentication via Notes logon on local PCSigner access granted via ECL on local PCLogging accessible from Help → Support → View Log on local PC
  11. 11. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event ModelSummary
  12. 12. 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
  13. 13. 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
  14. 14. XPages Control LanguagesLiteral values Strings, booleans etcExpression Language #{document1.FirstName}SSJS #{javascript:document1.getItemValueString(“FirstName”)}Custom All of the above
  15. 15. DEMO
  16. 16. Performance of LanguagesThe fewer controls the better= less Java code to be runReason for Extension Library controls Combines multiple controls into one Java classCombining languages is goodEL is quicker than SSJS
  17. 17. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event ModelSummary
  18. 18. 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
  19. 19. 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.properties editorPackage Explorer → WebContentWEB- INFxsp.properties
  20. 20. Persistence
  21. 21. Demo
  22. 22. AgendaIntroductionXPages Server ProcessingJVM and the NSFMemory ManagementJSF Event ModelSummary
  23. 23. JSF LifeCycle
  24. 24. 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
  25. 25. 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
  26. 26. AbstractPhaseListenerAbstract because it cant be instantiatedImplements javax.faces.event.PhaseListenerAllows us to track JSF lifecycle phasesJava class plus reference in faces-config
  27. 27. DEMO
  28. 28. Basic ProcessingValidation fails beforeRestoreView afterRestoreView beforeApplyRequestValues afterApplyRequestValues beforeProcessValidations beforeRenderResponse afterRenderResponseEvent logic not run
  29. 29. 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
  30. 30. immediate=“true”Validation fails beforeRestoreView afterRestoreView beforeApplyRequestValues afterApplyRequestValues beforeRenderResponse afterRenderResponseEvent logic run in ApplyRequestValues phaseComponent value never goes past submittedValueComponent tree not updated
  31. 31. Performance SmackdownCompute on Page Load (Loaded)Compute Dynamically (Runtime)ThemedataContexts “Global variables” Scoped to XPage, Custom Control, Panel Referenced via EL – #{var1}
  32. 32. Performance SmackdownPage Load – how many callsPartial Refresh – how many callsexecMode=“partial” Runs over only part of component tree
  33. 33. DEMO
  34. 34. 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
  35. 35. 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
  36. 36. SummaryScoped variables not cleared by ?logoutCombining controls improves performancePersistence options can optimise applicationJSF lifecycle affects event processingLoaded and dataContexts offer benefitsexecMode improves performance
  37. 37. SummaryScript libraries work for application reusabilitydataContexts better for page reusabilityVariableResolver best for application-level reusabilityUpgrade VariableResolver to ELResolver when XPages updated to JSF 2.0Use AbstractPhaseListener to test
  38. 38. Combining Controls Results
  39. 39. Language Lifecycle Results
  40. 40. Code Location Results
  41. 41. 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
  42. 42. Thank You, Questions & EvalsPaul Withers, Intec Systems LtdEmail: pwithers@intec.co.ukTwitter: paulswithersBlog: www.intec.co.uk/blog Please complete evaluations

×