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

Post on 31-Aug-2014

807 Views

Category:

Technology

6 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

07-04-2023 @EngageUG #engageug 1

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

Frank van der Linden

07-04-2023 @EngageUG #engageug 2

@flinden68

http://flinden68.wordpress.com

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

fli@e-office.com

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

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

07-04-2023 @EngageUG #engageug 5

Notes objects in memory

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

07-04-2023 @EngageUG #engageug 7

What is Serialization

07-04-2023 @EngageUG #engageug 8

XPages Java doc to the rescue

07-04-2023 @EngageUG #engageug 9

Put Notes document in memory• Get Notesdocument

• Wrap Notesdocument into a DominoDocument

07-04-2023 @EngageUG #engageug 10

Access fields• First check if document isRecycled

• Access field

07-04-2023 @EngageUG #engageug 11

On a XPage and more• In a computed field

• In an edit box

• Update the backend document

07-04-2023 @EngageUG #engageug 12

Demo

07-04-2023 @EngageUG #engageug 13

What about attachments• Get easy access to your attachements

07-04-2023 @EngageUG #engageug 14

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

• Call the attachment URL

07-04-2023 @EngageUG #engageug 15

Demo

07-04-2023 @EngageUG #engageug 16

Use buildin JSON classes

07-04-2023 @EngageUG #engageug 17

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

07-04-2023 @EngageUG #engageug 18

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

07-04-2023 @EngageUG #engageug 19

Managed beans

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

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

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

07-04-2023 @EngageUG #engageug 23

Java tips for XPages

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

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)

07-04-2023 @EngageUG #engageug 26

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

07-04-2023 @EngageUG #engageug 27

Extending a class• Using the class

• In a XPage

07-04-2023 @EngageUG #engageug 28

Questions

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

07-04-2023 @EngageUG #engageug 30

@flinden68

http://flinden68.wordpress.com

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

fli@e-office.com

Thank you

07-04-2023 @EngageUG #engageug 31

Bonus

07-04-2023 @EngageUG #engageug 32

Event Source

07-04-2023 @EngageUG #engageug 33

Customizable Toolbar

top related