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 elstar IT 
• OpenNTF director 
• Speak at several national and international 
events 
• IBM Champion 2013 and 2014 
• Live in the Netherlands 
• Work everywhere 
@flinden68 
http://nl.linkedin.com/in/flinden68 
flinden68@elstarit.nl 
http://www.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
XPages Java 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 XPage and 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 XPinc and 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 registrated in 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 TimeDifference horror 
• 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 EasyMock or Mockito, to simulate objects
Unit test for XPages 
• More and more Java code in XPages development 
• Write Unit test for better code 
• On OpenNTF Junit test for Xpages project (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://nl.linkedin.com/in/flinden68 
http://www.elstarit.nl 
flinden68@elstarit.nl 
https://bitbucket.org/flinden68/bccon-java-demo/src
Bonus
Eventsource
Customizable Toolbar

More Related Content

What's hot (20)

PPTX
SOA with PHP and Symfony
MichalSchroeder
 
PDF
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
PDF
Lo4
liankei
 
PDF
What's New and Next in OpenNTF Domino API (ICON UK 2014)
Paul Withers
 
PPTX
ASP.NET vNext
Alex Thissen
 
PPTX
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
idrsolutions
 
PPTX
A SOA approximation on symfony
Joseluis Laso
 
PDF
Agile sites311training
Michele Sciabarrà
 
PDF
CFWheels - Pragmatic, Beautiful Code
indiver
 
PDF
CrossWorlds: Unleash the Power of Domino for Connections Development
LetsConnect
 
PPTX
La vita nella corsia di sorpasso; A tutta velocità, XPages!
Ulrich Krause
 
PPTX
An XPager's Guide to Process Server-Side Jobs on Domino
Frank van der Linden
 
PDF
Stackato v2
Jonas Brømsø
 
PDF
Eureka Moment UKLUG
Paul Withers
 
PPTX
Debugging your Way through .NET with Visual Studio 2015
Ido Flatow
 
PDF
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
Paul Withers
 
PPTX
They why behind php frameworks
Kirk Madera
 
PDF
Introduction to XPConnect
Anant Narayanan
 
PPTX
Container Orchestration for .NET Developers
Mike Melusky
 
PDF
Infinum Android Talks #09 - DBFlow ORM
Infinum
 
SOA with PHP and Symfony
MichalSchroeder
 
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
Lo4
liankei
 
What's New and Next in OpenNTF Domino API (ICON UK 2014)
Paul Withers
 
ASP.NET vNext
Alex Thissen
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
idrsolutions
 
A SOA approximation on symfony
Joseluis Laso
 
Agile sites311training
Michele Sciabarrà
 
CFWheels - Pragmatic, Beautiful Code
indiver
 
CrossWorlds: Unleash the Power of Domino for Connections Development
LetsConnect
 
La vita nella corsia di sorpasso; A tutta velocità, XPages!
Ulrich Krause
 
An XPager's Guide to Process Server-Side Jobs on Domino
Frank van der Linden
 
Stackato v2
Jonas Brømsø
 
Eureka Moment UKLUG
Paul Withers
 
Debugging your Way through .NET with Visual Studio 2015
Ido Flatow
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
Paul Withers
 
They why behind php frameworks
Kirk Madera
 
Introduction to XPConnect
Anant Narayanan
 
Container Orchestration for .NET Developers
Mike Melusky
 
Infinum Android Talks #09 - DBFlow ORM
Infinum
 

Viewers also liked (9)

PPTX
Don't worry with bower
Frank van der Linden
 
PPTX
A (XPages) developers guide to Cloudant
Frank van der Linden
 
PPTX
A (XPages) developers guide to Cloudant - MeetIT
Frank van der Linden
 
PPTX
Let's serve your data
Frank van der Linden
 
PPT
guncel pazarlama yaklasimlari
kesinkesin
 
PPTX
The future of web development write once, run everywhere with angular.js and ...
Mark Roden
 
PPTX
Angular.js in XPages
Mark Roden
 
PPTX
Dnug2012 yellow and blue stream
Frank van der Linden
 
DOCX
Data entry clerk performance appraisal
abigailperry519
 
Don't worry with bower
Frank van der Linden
 
A (XPages) developers guide to Cloudant
Frank van der Linden
 
A (XPages) developers guide to Cloudant - MeetIT
Frank van der Linden
 
Let's serve your data
Frank van der Linden
 
guncel pazarlama yaklasimlari
kesinkesin
 
The future of web development write once, run everywhere with angular.js and ...
Mark Roden
 
Angular.js in XPages
Mark Roden
 
Dnug2012 yellow and blue stream
Frank van der Linden
 
Data entry clerk performance appraisal
abigailperry519
 
Ad

Similar to Bccon use notes objects in memory and other useful (20)

PDF
ics user group dev day_2014 use notes objects in memory and other useful
ICS User Group
 
PDF
A Notes Developer's Journey into Java
Teamstudio
 
PPTX
XPages and Java (DanNotes 50th conference, November 2013)
Per Henrik Lausten
 
PDF
Java for XPages Development
Teamstudio
 
DOCX
Xpages
mohammed shafi
 
PDF
XPages Blast - Lotusphere 2011
Tim Clark
 
PDF
XPages Blast - Lotusphere 2013
Tim Clark
 
PPTX
X page developer
Jakob Majkilde
 
PDF
Tips for Building your First XPages Java Application
Teamstudio
 
PDF
X pages jumpstart jmp101
pdhannan
 
PDF
Icsug conf 14_dev02_xpages-coffe-from-a-friend-using-third-party-java-libraries
ICS User Group
 
PDF
XPages Blast - ILUG 2010
Tim Clark
 
PDF
XPages Blast - Ideas, Tips and More
Teamstudio
 
PDF
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
ICS User Group
 
PDF
Take a Trip Into the Forest: A Java Primer on Maps, Trees, and Collections
Teamstudio
 
PDF
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
Russell Maher
 
PDF
jQuery: The World's Most Popular JavaScript Library Comes to XPages
Teamstudio
 
PDF
XPages Blast - Lotusphere 2012
Tim Clark
 
PDF
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
Howard Greenberg
 
PDF
Twelve Tasks Made Easier with IBM Domino XPages
Teamstudio
 
ics user group dev day_2014 use notes objects in memory and other useful
ICS User Group
 
A Notes Developer's Journey into Java
Teamstudio
 
XPages and Java (DanNotes 50th conference, November 2013)
Per Henrik Lausten
 
Java for XPages Development
Teamstudio
 
XPages Blast - Lotusphere 2011
Tim Clark
 
XPages Blast - Lotusphere 2013
Tim Clark
 
X page developer
Jakob Majkilde
 
Tips for Building your First XPages Java Application
Teamstudio
 
X pages jumpstart jmp101
pdhannan
 
Icsug conf 14_dev02_xpages-coffe-from-a-friend-using-third-party-java-libraries
ICS User Group
 
XPages Blast - ILUG 2010
Tim Clark
 
XPages Blast - Ideas, Tips and More
Teamstudio
 
bccon-2014 dev02 xpages-coffe-from-a-friend-using-third-party-java-libraries
ICS User Group
 
Take a Trip Into the Forest: A Java Primer on Maps, Trees, and Collections
Teamstudio
 
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
Russell Maher
 
jQuery: The World's Most Popular JavaScript Library Comes to XPages
Teamstudio
 
XPages Blast - Lotusphere 2012
Tim Clark
 
MWLUG Session- AD112 - Take a Trip Into the Forest - A Java Primer on Maps, ...
Howard Greenberg
 
Twelve Tasks Made Easier with IBM Domino XPages
Teamstudio
 
Ad

More from Frank van der Linden (20)

PPTX
Engage Usergroup 2024 - The Good The Bad_The Ugly
Frank van der Linden
 
PDF
Engage 2020: Hello are you listening, There is stream for everything
Frank van der Linden
 
PDF
NCUG 2019: Super charge your API’s with Reactive streams
Frank van der Linden
 
PDF
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
Frank van der Linden
 
PDF
Engage 2019: The good, the bad and the ugly: a not so objective view on front...
Frank van der Linden
 
PDF
Social connections14: Super charge your API’s with Reactive streams
Frank van der Linden
 
PDF
Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...
Frank van der Linden
 
PDF
Spring forward: an introduction to Spring boot and Thymeleaf
Frank van der Linden
 
PDF
DEV03 - How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real...
Frank van der Linden
 
PDF
Wcs-1785 How Watson, Bluemix, Cloudant and XPages can work together in a real...
Frank van der Linden
 
PPTX
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
Frank van der Linden
 
PPTX
The power of dots
Frank van der Linden
 
PPTX
Let me introduce you: DOTS
Frank van der Linden
 
PPTX
Integrate domino designer with cvs source control
Frank van der Linden
 
PPTX
how to connect your app to the activity stream with x-pages
Frank van der Linden
 
ODP
Domino point2012 integrate domino designer with cvs source control
Frank van der Linden
 
PPTX
Entwickler camp2012 make the impossible possible with x_pages
Frank van der Linden
 
PPTX
Entwickler camp2012 how to connect your app to the activity stream with x_pages
Frank van der Linden
 
PPTX
Blug2012 yellow and blue stream
Frank van der Linden
 
PPT
Presa XPages Lotusphere Comes To 17/03/2011
Frank van der Linden
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Frank van der Linden
 
Engage 2020: Hello are you listening, There is stream for everything
Frank van der Linden
 
NCUG 2019: Super charge your API’s with Reactive streams
Frank van der Linden
 
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
Frank van der Linden
 
Engage 2019: The good, the bad and the ugly: a not so objective view on front...
Frank van der Linden
 
Social connections14: Super charge your API’s with Reactive streams
Frank van der Linden
 
Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...
Frank van der Linden
 
Spring forward: an introduction to Spring boot and Thymeleaf
Frank van der Linden
 
DEV03 - How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real...
Frank van der Linden
 
Wcs-1785 How Watson, Bluemix, Cloudant and XPages can work together in a real...
Frank van der Linden
 
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
Frank van der Linden
 
The power of dots
Frank van der Linden
 
Let me introduce you: DOTS
Frank van der Linden
 
Integrate domino designer with cvs source control
Frank van der Linden
 
how to connect your app to the activity stream with x-pages
Frank van der Linden
 
Domino point2012 integrate domino designer with cvs source control
Frank van der Linden
 
Entwickler camp2012 make the impossible possible with x_pages
Frank van der Linden
 
Entwickler camp2012 how to connect your app to the activity stream with x_pages
Frank van der Linden
 
Blug2012 yellow and blue stream
Frank van der Linden
 
Presa XPages Lotusphere Comes To 17/03/2011
Frank van der Linden
 

Bccon 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 elstar IT • OpenNTF director • Speak at several national and international events • IBM Champion 2013 and 2014 • Live in the Netherlands • Work everywhere @flinden68 http://nl.linkedin.com/in/flinden68 [email protected] http://www.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. XPages Java 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 XPage and 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 XPinc and 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 registrated in 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 TimeDifference horror • 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 EasyMock or Mockito, to simulate objects
  • 32. Unit test for XPages • More and more Java code in XPages development • Write Unit test for better code • On OpenNTF Junit test for Xpages project (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://nl.linkedin.com/in/flinden68 http://www.elstarit.nl [email protected] https://bitbucket.org/flinden68/bccon-java-demo/src
  • 35. Bonus