Top Banner
Use Notes objects in memory and other useful Java tips for XPages development Frank van der Linden 06-06-2022 @EngageUG #engageug 1
33

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

Aug 31, 2014

Download

Technology

Demo database, is here: https://www.dropbox.com/sh/jbm822yajou2xm5/J8ahSiI8CR
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Use notes objects in memory and other useful java tips for xpages development

07-04-2023 @EngageUG #engageug 1

Use Notes objects in memory and other useful Java tips for XPages development

Frank van der Linden

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

07-04-2023 @EngageUG #engageug 2

@flinden68

http://flinden68.wordpress.com

http://nl.linkedin.com/in/flinden68

[email protected]

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

07-04-2023 @EngageUG #engageug 3

DisclaimerAll 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

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

07-04-2023 @EngageUG #engageug 4

Roadmap• Notes objects in memory• Use of JSON• Managed beans• Java tip for XPages

• Date checks• Utility class• Extending classes• Use of finally

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

07-04-2023 @EngageUG #engageug 5

Notes objects in memory

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

07-04-2023 @EngageUG #engageug 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

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

07-04-2023 @EngageUG #engageug 7

What is Serialization

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

07-04-2023 @EngageUG #engageug 8

XPages Java doc to the rescue

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

07-04-2023 @EngageUG #engageug 9

Put Notes document in memory• Get Notesdocument

• Wrap Notesdocument into a DominoDocument

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

07-04-2023 @EngageUG #engageug 10

Access fields• First check if document isRecycled

• Access field

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

07-04-2023 @EngageUG #engageug 11

On a XPage and more• In a computed field

• In an edit box

• Update the backend document

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

07-04-2023 @EngageUG #engageug 12

Demo

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

07-04-2023 @EngageUG #engageug 13

What about attachments• Get easy access to your attachements

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

07-04-2023 @EngageUG #engageug 14

What about attachments• No calculation of paths• Works both in XPinc and Web

• Call the attachment URL

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

07-04-2023 @EngageUG #engageug 15

Demo

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

07-04-2023 @EngageUG #engageug 16

Use buildin JSON classes

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

07-04-2023 @EngageUG #engageug 17

JSON building classes• Part of the Extensibility API, since 8.5.2• Easy way to build JSON

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

07-04-2023 @EngageUG #engageug 18

JSON building classes• No concatenation of Strings• Faster• Readable code

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

07-04-2023 @EngageUG #engageug 19

Managed beans

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

07-04-2023 @EngageUG #engageug 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

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

07-04-2023 @EngageUG #engageug 21

Faces-config.xml syntax• Name of the bean• Full qualified class name• Scope of the bean• Optional, initialize properties

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

07-04-2023 @EngageUG #engageug 22

Use the managed beans• Do the calculation in the class• Use Expression Language to access properties• Minimize use of SSJS• Some examples

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

07-04-2023 @EngageUG #engageug 23

Java tips for XPages

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

07-04-2023 @EngageUG #engageug 24

Utility class• All kind of methods• Always available as static class• I added some methods who were

translated from SSJS

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

07-04-2023 @EngageUG #engageug 25

Date checks• Remember the TimeDifference horror• Java provide nice Date checks• Like… Date.before(Date) or Date.after(Date)

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

07-04-2023 @EngageUG #engageug 26

Extending a class• Extend a base class• Use the methods of the base class

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

07-04-2023 @EngageUG #engageug 27

Extending a class• Using the class

• In a XPage

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

07-04-2023 @EngageUG #engageug 28

Questions

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

07-04-2023 @EngageUG #engageug 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

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

07-04-2023 @EngageUG #engageug 30

@flinden68

http://flinden68.wordpress.com

http://nl.linkedin.com/in/flinden68

[email protected]

Thank you

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

07-04-2023 @EngageUG #engageug 31

Bonus

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

07-04-2023 @EngageUG #engageug 32

Event Source

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

07-04-2023 @EngageUG #engageug 33

Customizable Toolbar