Use Notes objects in
memory and other useful
Java tips for XPages
development
Frank van der Linden
17-3-2014 @EngageUG #en...
17-3-2014 @EngageUG #engageug 2
@flinden68
http://flinden68.wordpress.com
http://nl.linkedin.com/in/flinden68
fli@e-office...
Disclaimer
All the code and the demos in this session will use the Java
Notes Objects which are part of the IBM/Lotus Note...
Roadmap
• Notes objects in memory
• Use of JSON
• Managed beans
• Java tip for XPages
• Date checks
• Utility class
• Exte...
Notes objects in memory
17-3-2014 @EngageUG #engageug 5
Bad practice
• Notes objects are not serializable
• Will not recycled the Java way, it will keep a pointer to the
C object...
What is Serialization
17-3-2014 @EngageUG #engageug 7
XPages Java doc to the rescue
17-3-2014 @EngageUG #engageug 8
Put Notes document in memory
• Get Notesdocument
• Wrap Notesdocument into a DominoDocument
17-3-2014 @EngageUG #engageug 9
Access fields
• First check if document isRecycled
• Access field
17-3-2014 @EngageUG #engageug 10
On a XPage and more
• In a computed field
• In an edit box
• Update the backend document
17-3-2014 @EngageUG #engageug 11
Demo
17-3-2014 @EngageUG #engageug 12
What about attachments
• Get easy access to your attachements
17-3-2014 @EngageUG #engageug 13
What about attachments
• No calculation of paths
• Works both in XPinc and Web
• Call the attachment URL
17-3-2014 @Engage...
Demo
17-3-2014 @EngageUG #engageug 15
Use buildin JSON classes
17-3-2014 @EngageUG #engageug 16
JSON building classes
• Part of the Extensibility API, since 8.5.2
• Easy way to build JSON
17-3-2014 @EngageUG #engageug ...
JSON building classes
• No concatenation of Strings
• Faster
• Readable code
17-3-2014 @EngageUG #engageug 18
Managed beans
17-3-2014 @EngageUG #engageug 19
The requirements
• Needs to be Serializable
• At least one constructor without parameters
• Needs to be registrated in the...
Faces-config.xml syntax
• Name of the bean
• Full qualified class name
• Scope of the bean
• Optional, initialize properti...
Use the managed beans
• Do the calculation in the class
• Use Expression Language to access properties
• Minimize use of S...
Java tips for XPages
17-3-2014 @EngageUG #engageug 23
Utility class
• All kind of methods
• Always available as static class
• I added some methods who were
translated from SSJ...
Date checks
• Remember the TimeDifference horror
• Java provide nice Date checks
• Like… Date.before(Date) or Date.after(D...
Extending a class
• Extend a base class
• Use the methods of the base class
17-3-2014 @EngageUG #engageug 26
Extending a class
• Using the class
• In a XPage
17-3-2014 @EngageUG #engageug 27
Questions
17-3-2014 @EngageUG #engageug 28
Credits
• DominoDocument, thanks Jesse Gallaghar for pointing me in the right direction.
• Utility Class, the base taken f...
17-3-2014 @EngageUG #engageug 30
@flinden68
http://flinden68.wordpress.com
http://nl.linkedin.com/in/flinden68
fli@e-offic...
Bonus
17-3-2014 @EngageUG #engageug 31
Event Source
17-3-2014 @EngageUG #engageug 32
Customizable Toolbar
17-3-2014 @EngageUG #engageug 33
Upcoming SlideShare
Loading in …5
×

Use notes objects in memory and other useful java tips for xpages development

2,041 views

Published on

Demo database, is here: https://www.dropbox.com/sh/jbm822yajou2xm5/J8ahSiI8CR

Published in: Technology

Use notes objects in memory and other useful java tips for xpages development

  1. 1. Use Notes objects in memory and other useful Java tips for XPages development Frank van der Linden 17-3-2014 @EngageUG #engageug 1
  2. 2. 17-3-2014 @EngageUG #engageug 2 @flinden68 http://flinden68.wordpress.com http://nl.linkedin.com/in/flinden68 fli@e-office.com
  3. 3. Disclaimer All the code and the demos in this session will use the Java Notes Objects which are part of the IBM/Lotus Notes product. For a modern way of Java coding with Notes Objects please use the OpenNTF Domino API. Please visit the session of Paul Withers and Martin Jinoch. Or even better use OpenNTF essentials 17-3-2014 @EngageUG #engageug 3
  4. 4. Roadmap • Notes objects in memory • Use of JSON • Managed beans • Java tip for XPages • Date checks • Utility class • Extending classes • Use of finally 17-3-2014 @EngageUG #engageug 4
  5. 5. Notes objects in memory 17-3-2014 @EngageUG #engageug 5
  6. 6. Bad practice • Notes objects are not serializable • Will not recycled the Java way, it will keep a pointer to the C object • Can cause out of memory 17-3-2014 @EngageUG #engageug 6
  7. 7. What is Serialization 17-3-2014 @EngageUG #engageug 7
  8. 8. XPages Java doc to the rescue 17-3-2014 @EngageUG #engageug 8
  9. 9. Put Notes document in memory • Get Notesdocument • Wrap Notesdocument into a DominoDocument 17-3-2014 @EngageUG #engageug 9
  10. 10. Access fields • First check if document isRecycled • Access field 17-3-2014 @EngageUG #engageug 10
  11. 11. On a XPage and more • In a computed field • In an edit box • Update the backend document 17-3-2014 @EngageUG #engageug 11
  12. 12. Demo 17-3-2014 @EngageUG #engageug 12
  13. 13. What about attachments • Get easy access to your attachements 17-3-2014 @EngageUG #engageug 13
  14. 14. What about attachments • No calculation of paths • Works both in XPinc and Web • Call the attachment URL 17-3-2014 @EngageUG #engageug 14
  15. 15. Demo 17-3-2014 @EngageUG #engageug 15
  16. 16. Use buildin JSON classes 17-3-2014 @EngageUG #engageug 16
  17. 17. JSON building classes • Part of the Extensibility API, since 8.5.2 • Easy way to build JSON 17-3-2014 @EngageUG #engageug 17
  18. 18. JSON building classes • No concatenation of Strings • Faster • Readable code 17-3-2014 @EngageUG #engageug 18
  19. 19. Managed beans 17-3-2014 @EngageUG #engageug 19
  20. 20. The requirements • Needs to be Serializable • At least one constructor without parameters • Needs to be registrated in the Faces-config.xml • Properties have Getters and Setters 17-3-2014 @EngageUG #engageug 20
  21. 21. Faces-config.xml syntax • Name of the bean • Full qualified class name • Scope of the bean • Optional, initialize properties 17-3-2014 @EngageUG #engageug 21
  22. 22. Use the managed beans • Do the calculation in the class • Use Expression Language to access properties • Minimize use of SSJS • Some examples 17-3-2014 @EngageUG #engageug 22
  23. 23. Java tips for XPages 17-3-2014 @EngageUG #engageug 23
  24. 24. Utility class • All kind of methods • Always available as static class • I added some methods who were translated from SSJS 17-3-2014 @EngageUG #engageug 24
  25. 25. Date checks • Remember the TimeDifference horror • Java provide nice Date checks • Like… Date.before(Date) or Date.after(Date) 17-3-2014 @EngageUG #engageug 25
  26. 26. Extending a class • Extend a base class • Use the methods of the base class 17-3-2014 @EngageUG #engageug 26
  27. 27. Extending a class • Using the class • In a XPage 17-3-2014 @EngageUG #engageug 27
  28. 28. Questions 17-3-2014 @EngageUG #engageug 28
  29. 29. Credits • DominoDocument, thanks Jesse Gallaghar for pointing me in the right direction. • Utility Class, the base taken from the Help Application from OpenNTF • Presentation, reveal.js • Demo database runs on Domino 9.0.1 • Demo database needs the Extension Library from OpenNTF • XPages Java doc, http://public.dhe.ibm.com/software/dw/lotus/Domino- Designer/JavaDocs/XPagesExtAPI/8.5.2/index.html?overview-summary.html 17-3-2014 @EngageUG #engageug 29
  30. 30. 17-3-2014 @EngageUG #engageug 30 @flinden68 http://flinden68.wordpress.com http://nl.linkedin.com/in/flinden68 fli@e-office.com Thank you
  31. 31. Bonus 17-3-2014 @EngageUG #engageug 31
  32. 32. Event Source 17-3-2014 @EngageUG #engageug 32
  33. 33. Customizable Toolbar 17-3-2014 @EngageUG #engageug 33

×