SlideShare a Scribd company logo
1 of 37
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

SOA with PHP and Symfony
SOA with PHP and SymfonySOA with PHP and Symfony
SOA with PHP and SymfonyMichalSchroeder
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Ganesh Kondal
 
What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)Paul Withers
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug JavaWriting better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Javaidrsolutions
 
A SOA approximation on symfony
A SOA approximation on symfonyA SOA approximation on symfony
A SOA approximation on symfonyJoseluis Laso
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Codeindiver
 
CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development LetsConnect
 
La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!Ulrich Krause
 
An XPager's Guide to Process Server-Side Jobs on Domino
An XPager's Guide to Process Server-Side Jobs on DominoAn XPager's Guide to Process Server-Side Jobs on Domino
An XPager's Guide to Process Server-Side Jobs on DominoFrank van der Linden
 
Eureka Moment UKLUG
Eureka Moment UKLUGEureka Moment UKLUG
Eureka Moment UKLUGPaul Withers
 
Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015Ido Flatow
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...Paul Withers
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworksKirk Madera
 
Introduction to XPConnect
Introduction to XPConnectIntroduction to XPConnect
Introduction to XPConnectAnant Narayanan
 
Container Orchestration for .NET Developers
Container Orchestration for .NET DevelopersContainer Orchestration for .NET Developers
Container Orchestration for .NET DevelopersMike Melusky
 
Infinum Android Talks #09 - DBFlow ORM
Infinum Android Talks #09 - DBFlow ORMInfinum Android Talks #09 - DBFlow ORM
Infinum Android Talks #09 - DBFlow ORMInfinum
 

What's hot (20)

SOA with PHP and Symfony
SOA with PHP and SymfonySOA with PHP and Symfony
SOA with PHP and Symfony
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
Lo4
Lo4Lo4
Lo4
 
What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug JavaWriting better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
 
A SOA approximation on symfony
A SOA approximation on symfonyA SOA approximation on symfony
A SOA approximation on symfony
 
Agile sites311training
Agile sites311trainingAgile sites311training
Agile sites311training
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Code
 
CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development CrossWorlds: Unleash the Power of Domino for Connections Development
CrossWorlds: Unleash the Power of Domino for Connections Development
 
La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!La vita nella corsia di sorpasso; A tutta velocità, XPages!
La vita nella corsia di sorpasso; A tutta velocità, XPages!
 
An XPager's Guide to Process Server-Side Jobs on Domino
An XPager's Guide to Process Server-Side Jobs on DominoAn XPager's Guide to Process Server-Side Jobs on Domino
An XPager's Guide to Process Server-Side Jobs on Domino
 
Stackato v2
Stackato v2Stackato v2
Stackato v2
 
Eureka Moment UKLUG
Eureka Moment UKLUGEureka Moment UKLUG
Eureka Moment UKLUG
 
Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
Introduction to XPConnect
Introduction to XPConnectIntroduction to XPConnect
Introduction to XPConnect
 
Container Orchestration for .NET Developers
Container Orchestration for .NET DevelopersContainer Orchestration for .NET Developers
Container Orchestration for .NET Developers
 
Infinum Android Talks #09 - DBFlow ORM
Infinum Android Talks #09 - DBFlow ORMInfinum Android Talks #09 - DBFlow ORM
Infinum Android Talks #09 - DBFlow ORM
 

Viewers also liked

A (XPages) developers guide to Cloudant
A (XPages) developers guide to CloudantA (XPages) developers guide to Cloudant
A (XPages) developers guide to CloudantFrank van der Linden
 
A (XPages) developers guide to Cloudant - MeetIT
A (XPages) developers guide to Cloudant - MeetITA (XPages) developers guide to Cloudant - MeetIT
A (XPages) developers guide to Cloudant - MeetITFrank van der Linden
 
guncel pazarlama yaklasimlari
guncel pazarlama yaklasimlariguncel pazarlama yaklasimlari
guncel pazarlama yaklasimlarikesinkesin
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...Mark Roden
 
Angular.js in XPages
Angular.js in XPagesAngular.js in XPages
Angular.js in XPagesMark Roden
 
Data entry clerk performance appraisal
Data entry clerk performance appraisalData entry clerk performance appraisal
Data entry clerk performance appraisalabigailperry519
 

Viewers also liked (9)

Don't worry with bower
Don't worry with bowerDon't worry with bower
Don't worry with bower
 
A (XPages) developers guide to Cloudant
A (XPages) developers guide to CloudantA (XPages) developers guide to Cloudant
A (XPages) developers guide to Cloudant
 
A (XPages) developers guide to Cloudant - MeetIT
A (XPages) developers guide to Cloudant - MeetITA (XPages) developers guide to Cloudant - MeetIT
A (XPages) developers guide to Cloudant - MeetIT
 
Let's serve your data
Let's serve your dataLet's serve your data
Let's serve your data
 
guncel pazarlama yaklasimlari
guncel pazarlama yaklasimlariguncel pazarlama yaklasimlari
guncel pazarlama yaklasimlari
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...
 
Angular.js in XPages
Angular.js in XPagesAngular.js in XPages
Angular.js in XPages
 
Dnug2012 yellow and blue stream
Dnug2012 yellow and blue streamDnug2012 yellow and blue stream
Dnug2012 yellow and blue stream
 
Data entry clerk performance appraisal
Data entry clerk performance appraisalData entry clerk performance appraisal
Data entry clerk performance appraisal
 

Similar to Bccon use notes objects in memory and other useful

ics user group dev day_2014 use notes objects in memory and other useful
ics user group dev day_2014 use notes objects in memory and other usefulics user group dev day_2014 use notes objects in memory and other useful
ics user group dev day_2014 use notes objects in memory and other usefulICS User Group
 
A Notes Developer's Journey into Java
A Notes Developer's Journey into JavaA Notes Developer's Journey into Java
A Notes Developer's Journey into JavaTeamstudio
 
Java for XPages Development
Java for XPages DevelopmentJava for XPages Development
Java for XPages DevelopmentTeamstudio
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIPaul Withers
 
Selenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdfSelenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdfAnanthReddy38
 
Selenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdfSelenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdfAnanthReddy38
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011Graham Weldon
 
Testing-Tools-Magnitia-Content.pdf
Testing-Tools-Magnitia-Content.pdfTesting-Tools-Magnitia-Content.pdf
Testing-Tools-Magnitia-Content.pdfAnanthReddy38
 
Beyond Domino Designer
Beyond Domino DesignerBeyond Domino Designer
Beyond Domino DesignerPaul Withers
 
Best Java Online Training in India
Best Java Online Training in IndiaBest Java Online Training in India
Best Java Online Training in IndiaNagendra Kumar
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfullyTEST Huddle
 
Selenium web driver_2.0_presentation
Selenium web driver_2.0_presentationSelenium web driver_2.0_presentation
Selenium web driver_2.0_presentationsayhi2sudarshan
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introductionjyoti_lakhani
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovypaulbowler
 
How Class Data Sharing Can Speed up Your Jakarta EE Application Startup
How Class Data Sharing Can Speed up Your Jakarta EE Application StartupHow Class Data Sharing Can Speed up Your Jakarta EE Application Startup
How Class Data Sharing Can Speed up Your Jakarta EE Application StartupRudy De Busscher
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, SuccessfullySauce Labs
 

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

ics user group dev day_2014 use notes objects in memory and other useful
ics user group dev day_2014 use notes objects in memory and other usefulics user group dev day_2014 use notes objects in memory and other useful
ics user group dev day_2014 use notes objects in memory and other useful
 
A Notes Developer's Journey into Java
A Notes Developer's Journey into JavaA Notes Developer's Journey into Java
A Notes Developer's Journey into Java
 
Java for XPages Development
Java for XPages DevelopmentJava for XPages Development
Java for XPages Development
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
 
Selenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdfSelenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdf
 
Selenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdfSelenium-with-Java-Course-Content-Magnitia.pdf
Selenium-with-Java-Course-Content-Magnitia.pdf
 
CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011CakePHP 2.0 - PHP Matsuri 2011
CakePHP 2.0 - PHP Matsuri 2011
 
Testing-Tools-Magnitia-Content.pdf
Testing-Tools-Magnitia-Content.pdfTesting-Tools-Magnitia-Content.pdf
Testing-Tools-Magnitia-Content.pdf
 
Beyond Domino Designer
Beyond Domino DesignerBeyond Domino Designer
Beyond Domino Designer
 
Java Online Training
Java Online TrainingJava Online Training
Java Online Training
 
Best Java Online Training in India
Best Java Online Training in IndiaBest Java Online Training in India
Best Java Online Training in India
 
Java and the JVM
Java and the JVMJava and the JVM
Java and the JVM
 
Introduction to oops
Introduction to oopsIntroduction to oops
Introduction to oops
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
Selenium web driver_2.0_presentation
Selenium web driver_2.0_presentationSelenium web driver_2.0_presentation
Selenium web driver_2.0_presentation
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovy
 
How Class Data Sharing Can Speed up Your Jakarta EE Application Startup
How Class Data Sharing Can Speed up Your Jakarta EE Application StartupHow Class Data Sharing Can Speed up Your Jakarta EE Application Startup
How Class Data Sharing Can Speed up Your Jakarta EE Application Startup
 
How to Use Selenium, Successfully
How to Use Selenium, SuccessfullyHow to Use Selenium, Successfully
How to Use Selenium, Successfully
 

More from Frank van der Linden

Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Engage 2020: Hello are you listening, There is stream for everything
Engage 2020: Hello are you listening, There is stream for everythingEngage 2020: Hello are you listening, There is stream for everything
Engage 2020: Hello are you listening, There is stream for everythingFrank van der Linden
 
NCUG 2019: Super charge your API’s with Reactive streams
NCUG 2019: Super charge your API’s with Reactive streamsNCUG 2019: Super charge your API’s with Reactive streams
NCUG 2019: Super charge your API’s with Reactive streamsFrank van der Linden
 
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...NCUG 2019: Spring forward: an introduction to Spring boot and Thymeleaf for (...
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...
Engage 2019: The good, the bad and the ugly: a not so objective view on front...Engage 2019: The good, the bad and the ugly: a not so objective view on front...
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
Social connections14: Super charge your API’s with Reactive streamsSocial connections14: Super charge your API’s with Reactive streams
Social connections14: Super charge your API’s with Reactive streamsFrank van der Linden
 
Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...
Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...Icon UK 2018 - Spring forward: an introduction to Spring boot and Thymeleaf f...
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
Spring forward: an introduction to Spring boot and ThymeleafSpring forward: an introduction to Spring boot and Thymeleaf
Spring forward: an introduction to Spring boot and ThymeleafFrank van der Linden
 
DEV03 - How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real...
DEV03 - How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real...DEV03 - How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Real...
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...
Wcs-1785 How Watson, Bluemix, Cloudant and XPages can work together in a real...Wcs-1785 How Watson, Bluemix, Cloudant and XPages can work together in a real...
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...
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...Frank van der Linden
 
Integrate domino designer with cvs source control
Integrate domino designer with cvs source controlIntegrate domino designer with cvs source control
Integrate domino designer with cvs source controlFrank van der Linden
 
how to connect your app to the activity stream with x-pages
how to connect your app to the activity stream with x-pageshow to connect your app to the activity stream with x-pages
how to connect your app to the activity stream with x-pagesFrank van der Linden
 
Domino point2012 integrate domino designer with cvs source control
Domino point2012 integrate domino designer with cvs source controlDomino point2012 integrate domino designer with cvs source control
Domino point2012 integrate domino designer with cvs source controlFrank van der Linden
 
Entwickler camp2012 make the impossible possible with x_pages
Entwickler camp2012 make the impossible possible with x_pagesEntwickler camp2012 make the impossible possible with x_pages
Entwickler camp2012 make the impossible possible with x_pagesFrank van der Linden
 
Entwickler camp2012 how to connect your app to the activity stream with x_pages
Entwickler camp2012 how to connect your app to the activity stream with x_pagesEntwickler camp2012 how to connect your app to the activity stream with x_pages
Entwickler camp2012 how to connect your app to the activity stream with x_pagesFrank van der Linden
 
Presa XPages Lotusphere Comes To 17/03/2011
Presa XPages Lotusphere Comes To 17/03/2011Presa XPages Lotusphere Comes To 17/03/2011
Presa XPages Lotusphere Comes To 17/03/2011Frank van der Linden
 

More from Frank van der Linden (20)

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

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 flinden68@elstarit.nl 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 flinden68@elstarit.nl https://bitbucket.org/flinden68/bccon-java-demo/src
  • 35. Bonus