SlideShare a Scribd company logo
Use Notes objects in memory and other useful Java tips for XPages development 
Frank van der Linden
Me 
•Java/XPages/Web/Domino developer 
•Self employed at elstarIT 
•OpenNTF director 
•Speak at several national and international events 
•IBM Champion 2013 and 2014 
•Live in the Netherlands 
•Work everywhere 
@flinden68 
http://www.elstarit.nl 
http://nl.linkedin.com/in/flinden68 
flinden68@elstarit.nl
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. 
Or even better use OpenNTF essentials
Roadmap 
•Notes objects in memory 
•Use of JSON 
•MVC/Managed beans 
•Java tip for XPages 
•Date checks 
•Utility class 
•Extending classes 
•Unit test 
•Finally 
•Some bonus code
Notes objects in memory
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
What is serialization
XPagesJava doc to the rescue
Put Notes document in memory 
•Get Notesdocument 
•Wrap Notesdocument into a DominoDocument
Get field values 
•First check if document isRecycled 
•Access field
On a XPageand more 
•In a computed field 
•In an edit box 
•Update the backend document
Demo
What about attachments 
•Get easy access to your attachments
What about attachments 
•No calculation of paths 
•Works both in XPincand Web 
•Call the attachment URL
Demo
Use build-in JSON classes
JSON building classes 
•Part of the Extensibility API, since 8.5.2 
•Easy way to build JSON
JSON building classes 
•No concatenation of Strings 
•Faster 
•Readable code
MVC
MVC
MVC for XPages 
•Separation of responsibility 
•Cleaner code 
•Easier to maintain 
•Model = documents 
•View = XPage 
•Controller = Java managed bean
Managed beans
The requirements 
•Needs to be Serializable 
•At least one constructor without parameters 
•Needs to be registratedin the Faces-config.xml 
•Properties are private 
•And have Getters and Setters
Faces-config.xml syntax 
•In package-explorer, under WebContentWEB-INF 
•Name of the bean 
•Full qualified class name 
•Scope of the bean 
•Optional, initialize properties
Use the managed beans 
•Do the calculation in the class 
•Use Expression Language to access properties 
•Minimize use of SSJS 
•Some examples
Java tips for XPages
Utility class 
•All kind of methods 
•Always available as static class 
•I added some methods who were translated from SSJS
Date checks 
•Remember the TimeDifferencehorror 
•Java provide nice Date checks 
•Like… Date.before(Date) or Date.after(Date)
Extending a class 
•Extend a base class 
•Use the methods of the base class
Extending a class 
•Using the class 
•In a XPage
Unit test 
•Write code to test small portions of code, like methods 
•Test if the code is doing what was intended 
•Write better Java code 
•Use Mock Framework, like EasyMockor Mockito, to simulate objects
Unit test for XPages 
•More and more Java code in XPagesdevelopment 
•Write Unit test for better code 
•On OpenNTF Junit test for Xpagesproject (thanks Christian Guedemann)
And Finally 
•Finally will always called, even after a catch 
•Use it to recycle objects and close stream readers
Thank you 
@flinden68 
http://www.elstarit.nl 
http://nl.linkedin.com/in/flinden68 
flinden68@elstarit.nl 
https://bitbucket.org/flinden68/bccon-java-demo/src
Bonus
Eventsource
Customizable Toolbar

More Related Content

PPTX
Use notes objects in memory and other useful java tips for xpages development
PPTX
Bccon use notes objects in memory and other useful
PPTX
JAVA FEATURES
PDF
ES2015 / ES6: Basics of modern Javascript
PDF
EclipseCon Europe 2011
PPTX
Java Programming
 
Use notes objects in memory and other useful java tips for xpages development
Bccon use notes objects in memory and other useful
JAVA FEATURES
ES2015 / ES6: Basics of modern Javascript
EclipseCon Europe 2011
Java Programming
 

What's hot (20)

PPT
Introduction to oops
PPTX
Features of java
PPTX
QSpiders - Jdk Jvm Jre and Jit
PPTX
Learn JAVA at ASIT
PPTX
QSpiders - Memory (JVM architecture)
PPT
Basic javaprogramming(session1)
PPTX
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
PPT
Java-java virtual machine
PPT
Java introduction
PPTX
Introduction to Core Java Programming
PPTX
Java virtual machine
PPTX
Php traits
PPTX
Java introduction
DOCX
JDK,JRE,JVM
PPTX
Java byte code presentation
PDF
Java Virtual Machine - Internal Architecture
PDF
Alexander Kutsan "Where Unicorns Live or How To Write Good C++ Code"
PPTX
Features of java - javatportal
Introduction to oops
Features of java
QSpiders - Jdk Jvm Jre and Jit
Learn JAVA at ASIT
QSpiders - Memory (JVM architecture)
Basic javaprogramming(session1)
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java-java virtual machine
Java introduction
Introduction to Core Java Programming
Java virtual machine
Php traits
Java introduction
JDK,JRE,JVM
Java byte code presentation
Java Virtual Machine - Internal Architecture
Alexander Kutsan "Where Unicorns Live or How To Write Good C++ Code"
Features of java - javatportal
Ad

Similar to ics user group dev day_2014 use notes objects in memory and other useful (20)

PDF
A Notes Developer's Journey into Java
PPTX
XPages and Java (DanNotes 50th conference, November 2013)
PDF
Java for XPages Development
DOCX
PDF
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
PDF
XPages Blast - Lotusphere 2013
PDF
XPages Blast - Lotusphere 2011
PDF
Icsug conf 14_dev02_xpages-coffe-from-a-friend-using-third-party-java-libraries
PDF
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
PDF
Twelve Tasks Made Easier with IBM Domino XPages
PDF
X pages jumpstart jmp101
PPTX
X page developer
PDF
XPages Blast - Lotusphere 2012
PDF
XPages Blast - Ideas, Tips and More
PDF
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
PDF
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
PPTX
Entwickler camp2012 make the impossible possible with x_pages
PDF
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
PDF
Marty, You're Just Not Thinking Fourth Dimensionally
PDF
Connect 2014 JMP101: Java for XPages Development
A Notes Developer's Journey into Java
XPages and Java (DanNotes 50th conference, November 2013)
Java for XPages Development
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
XPages Blast - Lotusphere 2013
XPages Blast - Lotusphere 2011
Icsug conf 14_dev02_xpages-coffe-from-a-friend-using-third-party-java-libraries
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
Twelve Tasks Made Easier with IBM Domino XPages
X pages jumpstart jmp101
X page developer
XPages Blast - Lotusphere 2012
XPages Blast - Ideas, Tips and More
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
Entwickler camp2012 make the impossible possible with x_pages
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
Marty, You're Just Not Thinking Fourth Dimensionally
Connect 2014 JMP101: Java for XPages Development
Ad

More from ICS User Group (20)

PDF
Domino Security Present and Future ConnectED Review - ICS.UG 2016
PDF
Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016
PDF
IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016
PDF
Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016
PDF
Private Cloud Storage - ICS.UG 2016
PDF
Die mobile Herausforderung meistern! - ICS.UG 2016
PDF
Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016
PDF
Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016
PDF
OpenNTF - From Donation to Contribution - ICS.UG 2016
PDF
Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...
PDF
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
PDF
XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016
PDF
Die Zukunft spricht Domino! - ICS.UG 2016
PDF
Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016
PDF
Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016
PDF
IBM Digital Experience Overview - ICS.UG 2016
PDF
Watson - Bitte-helfen-Sie - ICS.UG 2016
PDF
Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016
PDF
Beyond XPages ICS.UG 2015
PDF
ATLUG comes to you ICS.UG 2015
Domino Security Present and Future ConnectED Review - ICS.UG 2016
Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016
IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016
Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016
Private Cloud Storage - ICS.UG 2016
Die mobile Herausforderung meistern! - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016
OpenNTF - From Donation to Contribution - ICS.UG 2016
Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016
Die Zukunft spricht Domino! - ICS.UG 2016
Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016
Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016
IBM Digital Experience Overview - ICS.UG 2016
Watson - Bitte-helfen-Sie - ICS.UG 2016
Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016
Beyond XPages ICS.UG 2015
ATLUG comes to you ICS.UG 2015

Recently uploaded (20)

PPTX
2025-08-10 Joseph 02 (shared slides).pptx
PPTX
Tablets And Capsule Preformulation Of Paracetamol
DOCX
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
PDF
Instagram's Product Secrets Unveiled with this PPT
PPTX
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
PDF
natwest.pdf company description and business model
PPTX
Learning-Plan-5-Policies-and-Practices.pptx
PPTX
Effective_Handling_Information_Presentation.pptx
PPTX
Human Mind & its character Characteristics
PPTX
Emphasizing It's Not The End 08 06 2025.pptx
PPTX
nose tajweed for the arabic alphabets for the responsive
PPTX
fundraisepro pitch deck elegant and modern
PPTX
S. Anis Al Habsyi & Nada Shobah - Klasifikasi Hambatan Depresi.pptx
PPTX
Relationship Management Presentation In Banking.pptx
PPTX
INTERNATIONAL LABOUR ORAGNISATION PPT ON SOCIAL SCIENCE
PPTX
Impressionism_PostImpressionism_Presentation.pptx
PPTX
Project and change Managment: short video sequences for IBA
PPTX
chapter8-180915055454bycuufucdghrwtrt.pptx
PPTX
English-9-Q1-3-.pptxjkshbxnnxgchchxgxhxhx
PPTX
lesson6-211001025531lesson plan ppt.pptx
2025-08-10 Joseph 02 (shared slides).pptx
Tablets And Capsule Preformulation Of Paracetamol
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
Instagram's Product Secrets Unveiled with this PPT
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
natwest.pdf company description and business model
Learning-Plan-5-Policies-and-Practices.pptx
Effective_Handling_Information_Presentation.pptx
Human Mind & its character Characteristics
Emphasizing It's Not The End 08 06 2025.pptx
nose tajweed for the arabic alphabets for the responsive
fundraisepro pitch deck elegant and modern
S. Anis Al Habsyi & Nada Shobah - Klasifikasi Hambatan Depresi.pptx
Relationship Management Presentation In Banking.pptx
INTERNATIONAL LABOUR ORAGNISATION PPT ON SOCIAL SCIENCE
Impressionism_PostImpressionism_Presentation.pptx
Project and change Managment: short video sequences for IBA
chapter8-180915055454bycuufucdghrwtrt.pptx
English-9-Q1-3-.pptxjkshbxnnxgchchxgxhxhx
lesson6-211001025531lesson plan ppt.pptx

ics user group dev day_2014 use notes objects in memory and other useful

  • 1. Use Notes objects in memory and other useful Java tips for XPages development Frank van der Linden
  • 2. Me •Java/XPages/Web/Domino developer •Self employed at elstarIT •OpenNTF director •Speak at several national and international events •IBM Champion 2013 and 2014 •Live in the Netherlands •Work everywhere @flinden68 http://www.elstarit.nl http://nl.linkedin.com/in/flinden68 flinden68@elstarit.nl
  • 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. Or even better use OpenNTF essentials
  • 4. Roadmap •Notes objects in memory •Use of JSON •MVC/Managed beans •Java tip for XPages •Date checks •Utility class •Extending classes •Unit test •Finally •Some bonus code
  • 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
  • 8. XPagesJava doc to the rescue
  • 9. Put Notes document in memory •Get Notesdocument •Wrap Notesdocument into a DominoDocument
  • 10. Get field values •First check if document isRecycled •Access field
  • 11. On a XPageand more •In a computed field •In an edit box •Update the backend document
  • 12. Demo
  • 13. What about attachments •Get easy access to your attachments
  • 14. What about attachments •No calculation of paths •Works both in XPincand Web •Call the attachment URL
  • 15. Demo
  • 16. Use build-in JSON classes
  • 17. JSON building classes •Part of the Extensibility API, since 8.5.2 •Easy way to build JSON
  • 18. JSON building classes •No concatenation of Strings •Faster •Readable code
  • 19. MVC
  • 20. MVC
  • 21. MVC for XPages •Separation of responsibility •Cleaner code •Easier to maintain •Model = documents •View = XPage •Controller = Java managed bean
  • 23. The requirements •Needs to be Serializable •At least one constructor without parameters •Needs to be registratedin the Faces-config.xml •Properties are private •And have Getters and Setters
  • 24. Faces-config.xml syntax •In package-explorer, under WebContentWEB-INF •Name of the bean •Full qualified class name •Scope of the bean •Optional, initialize properties
  • 25. Use the managed beans •Do the calculation in the class •Use Expression Language to access properties •Minimize use of SSJS •Some examples
  • 26. Java tips for XPages
  • 27. Utility class •All kind of methods •Always available as static class •I added some methods who were translated from SSJS
  • 28. Date checks •Remember the TimeDifferencehorror •Java provide nice Date checks •Like… Date.before(Date) or Date.after(Date)
  • 29. Extending a class •Extend a base class •Use the methods of the base class
  • 30. Extending a class •Using the class •In a XPage
  • 31. Unit test •Write code to test small portions of code, like methods •Test if the code is doing what was intended •Write better Java code •Use Mock Framework, like EasyMockor Mockito, to simulate objects
  • 32. Unit test for XPages •More and more Java code in XPagesdevelopment •Write Unit test for better code •On OpenNTF Junit test for Xpagesproject (thanks Christian Guedemann)
  • 33. And Finally •Finally will always called, even after a catch •Use it to recycle objects and close stream readers
  • 34. Thank you @flinden68 http://www.elstarit.nl http://nl.linkedin.com/in/flinden68 flinden68@elstarit.nl https://bitbucket.org/flinden68/bccon-java-demo/src
  • 35. Bonus