SlideShare a Scribd company logo
Java for XPages Development
Tweet about this event: #XPages
and mention us: @teamstudio @TLCCLTD
@PaulDN @ptcalhoun
January 16, 2014
Courtney Carter

@teamstudio
teamstudio.com

Inbound Marketing Specialist

@TLCCLTD
Who We Are
• Our background is in creating tools for collaborative
computing in mid-size and large enterprises,
primarily for IBM Notes
• Easy-to-use tools for developers and administrators
• 2300+ active customers, 47 countries
• Offices in US, UK and Japan
• Entered mobile space in 2010 with Unplugged: easy
mobilization of Notes apps to Blackberry, Android
and iOS
Teamstudio Unplugged
• Your mobile Domino server: take your Notes apps
with you!
• End-users access Notes applications from mobile
devices whether online or offline
• Leverages existing skills and technology – XPages –
a replication model you already know
• Unplugged 3.0 recently released
• IBM Collaboration Solutions Award Winner 2013
Unplugged Templates
•

Continuity – Mobile offline access to
BCM programs

•

OneView Approvals – Expense
approvals; anywhere, anytime

•

CustomerView – lightweight CRM
framework for field sales and field
service teams
• Contacts – customer information database
• Activities – customer activity log
• Media – mobile offline file storage and access
• Next Teamstudio/TLCC webinar: February 13, 2014
• Next Wireless Wednesdays webinar: Part 2 on March 5, 2014
o Learn Domino mobile development

• IBM Connect: booth 114; Mobile Made Easy session
• Promotion:
o Get 20% off your order of 25+ licenses of Unplugged
Java in XPages Development
Your Host Today:

Howard Greenberg
TLCC
@TLCCLtd

#XPages
1
Upcoming and Recorded Webinars

Next Webinar – February 13th
Creating a Great XPages User Interface with Howard and Paul

www.tlcc.com/xpages-webinar

View Previous Webinars
(use url above)

2
Session

Date

JMP101: Java for XPages Development with Paul Calhoun

Sunday at 10:30

JMP102: Creating a Great XPages User Interface with Howard
and Paul D.

Sunday at 1:30

SHOW102: XPages: Still No Experience Necessary with Paul
Calhoun and Kathy Brown

Wednesday at 10:30

BP202: Rapid XPages Development Using the Application
Layout Control with Howard and Paul D.

Thursday at 11:15

Click here for more information and to signup
3
TLCC Courses and Services

• The Leader in Notes and Domino Training since
1997
• Self Paced Distance Learning Courses for
Notes/Domino
– XPages, Development, and Administration (user too!)

• OnSite Private Classes
• TLCC Mentoring Services
• Free demo courses
– Intro. To XPages Development
– Application Development 1

4
• Save hundreds and even Thousands of Dollars
on the most popular courses and packages
• Through January 31st
• No need to attend Connect
 But if you do, all certification tests are free!
 TLCC’s courses will help you get ready for the exams

Click here for more information
5
New TLCC Java Courses and Package

• Java 2 for XPages Development (9.0)
•
•
•
•

Debugging
Expression Language
JavaBeans and Managed Beans
Third Party Java Libraries

– On Sale for $599, save $300

• Java 1 for XPages Development (9.0)
– Covers the Java Language

• Java for XPages Package (Domino 9)
– Has both Java courses
– On Sale for only $999, save $500
– Until January 31st Only
6
Asking Questions

Q & A at the end!
Type in your
questions as they
come up
7
Your Presenters Today:

Paul Calhoun

NetNotes Solutions
@ptcalhoun

Paul Della-Nebbia
TLCC
@PaulDN

#XPages

8
Agenda

• The Java Language Fundamentals
• Domino Designer Settings
• Java Beans and Managed Beans
• Calling Java Code from an XPage
• Using the Expression Language
• Accessing Domino Objects
• Using Third Party Libraries
• Wrap Up

9
How do you eat an Elephant ?

• One Bite at a time !!!
• Learning Java™ is a lot like eating an Elephant !!
– It’s a big job !!
– And there’s no clear
place where to start !!

10
Resources …

• TLCC Courses
– Rapid XPages Development
– Java 1 for XPages Development
– Java 2 for XPages Development
• http://www.tlcc.com/admin/tlccsite.nsf/DeveloperView.xsp

11
Resources …

• Start with J2SE (Java 2 STANDARD Edition)
– This covers core Java functionality
• Syntax
• Data Types
• Constructs
• Core Classes
- java.lang
- java.io
- java.net
- etc.
– Allow 3-6 Months
http://www.oracle.com/technetwork/java/javase/overview/index.html
12
Resources

• Learn XML (not part of Sun Certification)
– XML Syntax
– DTD/XML Schema
– XSL
• XSLT
• XSL:FO
• Finally jump on the J2E bandwagon (In this order!)
– Servlets
– JSPs
– JSFs
– Allow another 3-6 months
• Then the rest of the J2E specification
– Allow another 3-6 months
13
Roadblocks

• Road Blocks on your Journey to Learning Java
– “Linear” thinking instead of thinking in “Objects”
• If you have done any LotusScript Class development you are on your way !

– Starting to learn Java with J2E applications (Servlets, JSPs)
– Trying to start with the Java Enterprise Technologies
– Try to learn Java in conjunction with a
HUGE Mission critical project
– Not applying what you learn EVERYDAY !!
• This is the MOST critical roadblock !!!

14
Very Wise Saying

“If the only tool you have is a hammer,
you tend to see every problem as a nail”

Abraham Maslow

15
Your XPages Development Toolbox

Formula Language

CSS
LotusScript

XML
dojo
Java

JavaScript

XSLT

jQuery
16
Is the Java Language still relevant ?

• The Tiobe index as of December 2013

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
17
Java Version in Notes / Domino

Java Standard Edition (J2SE)
Java 2 Java Development Kit (JDK)

Version 6.0

Used in Notes Domino 9.0 and 8.5

Java 2 Java Development Kit (JDK)

Version 1.5.0

Used in Notes Domino 8

Java 2 Software Development Kit (SDK) Version 1.4.2

Used in Notes Domino 7

Java 2 Software Development Kit (SDK)

Version 1.4.1 (EOL)

Java 2 Software Development Kit (SDK) Version 1.4.0 (EOL)
Java 2 Software Development Kit (SDK) Version 1.3.1

Used in Notes Domino 6

Java 2 Software Development Kit (SDK) Version 1.3.0 (EOL)
Java 2 Software Development Kit (SDK) Version 1.2.2
Java 1 JDK Development Kit (JDK)

Version 1.1.8

Used in Notes Domino 5

18
Agenda

• The Java Language Fundamentals
• Domino Designer Settings
• Java Beans and Managed Beans
• Calling Java Code from an XPage
• Using the Expression Language
• Accessing Domino Objects
• Using Third Party Libraries
• Wrap Up

19
Configure DDE for XPage Development

• There are several things that can be configured that
will make your Java in XPages development
experience easier
• The following are recommendations for setting
properties in the Domino Designer BEFORE you
start developing

20
Configure Memory

• Change your memory allocation
– Edit the jvm.properties file located in the client
installation directory under
• framework/rcp/deploy

21
Configure Memory

• Edit with any text editor
– Xmx – Total amount of RAM for
Designer AND Client
• Set to at least 512m
• Don’t set equal to the amount of
system RAM
– Xms – Starting Heap size
• Set to at least 128m
• Don’t set equal to Xmx value
– Xmca – Memory block size
• Set to at least 512k
• That’s a “k” NOT A “m”

• Always set in multiple of “4”
• Will not take effect until client is
restarted (if running when edited)

22
Show Heap

• Monitor Memory Used
• In Designer Preferences
– Select General
– Check “Show heap status”

• Even though this is a checkbox,
it does not “remember” the
setting.
– It has to be checked each time you
start Designer

• Heap status in the lower left
hand corner of Designer
– Monitor the amount of memory being
used
– Click the trash can icon to trigger
garbage collection

23
Configure XML Editor

• Set XML Editor formatting for viewing
XPage source
• In Designer preferences
– Select XML | XML Files | Editor
– Change Line width
– Check “Split multiple attributes each on a
new line”
– Check “Clear all blank lines”

• Any new XPages source will adhere
to these settings
• Existing XPages can be reformatted”
– keyboard shortcut is
<shift><ctrl><f>

24
Formatting Differences

• Before and after XPage Source Formatting

25
Java Editor Margin

• In the Designer Preferences dialog, choose:
Java > Code Style > Formatter
– Click the “New” button
– The included profiles can not be edited

26
Change Java Editor Margin

• Select the “Line Wrapping” tab
– Change the “Maximum line width:” property to at
least 120

27
Change Java Editor Margin

• Ensure your profile is the active profile and
save preferences

28
Agenda

• The Java Language Fundamentals
• Domino Designer Settings
• Java Beans and Managed Beans
• Calling Java Code from an XPage
• Using the Expression Language
• Accessing Domino Objects
• Using Third Party Libraries
• Wrap Up

29
Java Beans vs Managed Beans

• One of the most confusing issues when coding with Java
• A Java Bean is a Plain ‘ol Java Object (POJO) or Java class that
conforms to a specific programming convention

– Must have a public no-argument constructor, otherwise the default no
argument constructor is used
– Class properties (fields) must be defined as private and accessible using
standard public method calls
• Start with get, set, or is (used for boolean properties instead of get)
• Commonly referred to as "getter" and "setter" methods
– The class must implement java.io.Serializable to be technically qualified as a
JavaBean.
• This is not “necessary” but a best practice

• Up to the developer to follow these conventions when creating
a JavaBean

30
Java Beans vs Managed Beans

• So what is a Managed Bean?
• It is important to understand that it makes no difference if a
bean is going to be just a Java Bean or a Managed Bean, it is
coded the exact same way
– Nothing in the Java source code defines it as a "Managed Bean”
– This is all done in the framework, in our case, XPages

• Java Beans are NOT Managed Beans

– But they can be, they just need to be "managed”
– A Managed Bean follows all of the same conventions as a regular JavaBean, but is
"Managed" by virtue of being registered with the framework it is incorporated in
(like the XPages runtime framework)
– A Managed Bean has scope in the framework and its methods can be called directly
without the need to first instantiate an object variable for the Managed Bean
• This is the PRIMARY factor that separates Java Beans from Managed Beans

31
A Java Bean Example

• Lets start with a simple Java Bean Example

32
A Java Bean Example

• Public “getter” and “setters”

33
Calling the Methods from an XPage
• Button Code
– The SSJS Code
– In order to “use” the Java Bean Code it has to be instantiated (lines 1&2)
– The public getter and setter methods have to be called
importPackage(com.nnsu.beans);
var jce:MyBean = new MyBean();
jce.setFName("Paul");
jce.setLName("Calhoun");
jce.setAge(50);
jce.setHobbies(new
java.util.ArrayList(java.util.Arrays.asList(["Riding
Motorcycles","Playing with Grandkids"])));
var retOutput = jce.getFName()+ " "+
jce.getLName()+"</br>";
retOutput += "He is: " + jce.getAge()+"</br>";
for (var i=0;i<jce.getHobbies().size();i++)
{
retOutput += jce.getHobbies().get(i) +"</br>";
}
getComponent("computedField1").setValue(retOutput);
34
Demo: A Java Bean

35
Making a “Managed Bean”from the same code
• Java code becomes a “Managed Bean” when it is registered
with the framework it is running in (In our case XPages)
• Managed Beans are “Registered” in the faces-config.xml file
in the application they will be used in

36
Faces Config
• The faces-config.xml file is an xml file where managed beans are
defined using the following syntax:
<managed-bean>
<description>description</description>
<managed-bean-name>beanName</managed-bean-name>
<managed-bean-class>beanClass</managed-bean-class>
<managed-bean-scope>beanScope</managed-bean-scope>
</managed-bean>

• To “Register” the previous bean as a “Managed Bean” the syntax would
be:
<managed-bean>
<description>My Managed Bean</description>
<managed-bean-name>myBean</managed-bean-name>
<managed-beanclass>com.nnsu.beans.MyBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
37
Registration components

• The description is just that, a short description of what the bean
does
• The name will be the programmatic name the bean is
instantiated with
• The class is the full class path to the code in the application
• The scope is the “life” of the Managed Bean which can be:
– application - The bean is available for as long as the application is in memory
and is shared among all users of the application.
– session - The bean is available for the current user session and is unique for
each user.
– view - The bean is available for the life of the current "view" or XPage.
– request - The bean is available only while the content of the individual XPage is
being submitted.
– none - The bean is instantiated each time it is referenced. This is helpful if the
bean is referenced within another bean.

38
Calling the Methods from an XPage
• Button Code
– The SSJS Code
– To “use” the Managed Bean Code call the methods using the
defined bean name the code was registered with in the facesconfig.xml

39
Calling the Methods from an XPage
• Button Code
– Notice that the Bean is never instantiated. This is because the
framework (XPages) instantiates it when it is called the first time.
myBean.setFName("Paul");
myBean.setLName("Calhoun");
myBean.setAge(50);
myBean.setHobbies(new
java.util.ArrayList(java.util.Arrays.asList(["Riding
Motorcycles","Playing with Grandkids"])));
var retOutput = myBean.getFName()+ " "+
myBean.getLName()+"</br>";
retOutput += "He is: " + myBean.getAge()+"</br>";
for (var i=0;i<myBean.getHobbies().size();i++)
{
retOutput += myBean.getHobbies().get(i)
+"</br>";
}
getComponent("computedField1").setValue(retOutput);
40
Benefits of Managed Bean

• Managed Beans have scope

– The setter methods can be executed in one event and
– The getter methods executed in another event
– The methods of the managed bean can be used across multiple pages in
the same application

• So should Java Beans ALWAYS be Managed Beans??

– As a rule, NO !!!
– Only use Managed Beans when you need the values in the bean to
“persist” in your application
– If persistence is not required then just use POJO’s

41
Demo: Managed Beans

42
Agenda

• The Java Language Fundamentals
• Domino Designer Settings
• Java Beans and Managed Beans
• Calling Java Code from an XPage
• Using the Expression Language
• Accessing Domino Objects
• Using Third Party Libraries
• Wrap Up

43
Executing Java Code

• The only Java code that can be “called” from an XPage is:

– Java Code Elements
– Java Source Code in a source folders in the Virtual File System (VFS)
• Primarily prior to 9.0

– Code in .jar files located in the JARs folder
– Code in .jar files located in the WebContent/WEB-INF/lib folder
– Compiled .class and .jar files located in the jvm/lib/ext folder in the file
system

44
Java Code Elements
• Create Java source code that will be compiled into individual class files
when the project is built
• Java Code elements are automatically added to the classpath

45
Source code in source folders
• Java Source code located in a Java Source folder in the VFS can be seen in
the “Package Explorer” view of the XPages perspective
• Java Code in a “source” folder is automatically added to the classpath

46
Code in .jar files in the JARS design folder
• Locally developed or third party Java Archive Files (.jar) can be imported into
the Jar design element
• Classed in JAR elements are automatically added to the classpath

47
Compiled .class and .jar in jvm/lib/ext folder

• .class and .jar files located in this folder are available to all
applications running locally and on the server
– GOTCHA: Java source files (.java) files in this folder will not compile and
execute

• Java Code located in this folder is automatically added to the
classpath

48
Calling Methods from SSJS
• Java code is instantiated and called from a SSJS event
– Import the Java package (unless the default package was
used)(which is a VERY bad idea)
– Instantiate an instance of a class from the imported package
– Call a method from the instantiated class
– “Do something” with the results or return a status message

49
Demo: Calling Java code from SSJS

50
Agenda

• The Java Language Fundamentals
• Domino Designer Settings
• Java Beans and Managed Beans
• Calling Java Code from an XPage
• Using the Expression Language
• Accessing Domino Objects
• Using Third Party Libraries
• Wrap Up

51
Expression Language

A scripting syntax in tag languages (JSP, JSF, XSP) to
invoke the properties and methods of back end Java
classes (specifically Java Beans).
• begins with a # or $ character and is enclosed in curly brackets {}
${sessionScope.myVar} - evaluated once on page load
#{sessionScope.myVar} - evaluated on page load, restore, renderResponse
• must be written on a single line
• evaluated from left to right … inner statements within the expression can
be delimited using parenthesis for precedence
• can concatenate several EL expressions to return a single string value …
${config.app.path}${config.app.custApp}

• You can NOT nest an EL expression within another EL expression
• An EL expression can return an object or value of any type
52
Bracket and Dot Notation

• Bracket notation:
#{viewScope[“viewName”]}
${header[“User-Agent”]}

• Dot notation:
#{viewScope.viewName}
${header.User-Agent}

• Can combine and chain expressions:
${facesContext["externalContext"]["requestServletPath"]}
${facesContext.externalContext["requestServletPath"]}
${facesContext.externalContext.requestServletPath}
${facesContext["externalContext"].requestServletPath}

53
EL Operators

54
Use EL to … Bind Controls to Fields in a Data Source

55
Use EL to … Get and Set Scoped Variables

56
Use EL to … Get and Set Properties in JavaBeans

57
Use EL to … Get and Set Properties in Managed Beans

58
Demo: Domino Objects

59
Agenda

• The Java Language Fundamentals
• Domino Designer Settings
• Java Beans and Managed Beans
• Calling Java Code from an XPage
• Using the Expression Language
• Accessing Domino Objects
• Using Third Party Libraries
• Wrap Up

60
Session

• The Notes Session object is the top level object in the
Domino class hierarchy
• The starting point for calling all other classes
(database, view, etc) in the hierarchy
• Two ways to get the session object in Java code
executed from an XPage
– Pass it in as a parameter from the SSJS
– Get it from the JSF “context”, the underlying
architecture

61
Session

• Pass the global “session” variable in as a parameter
– The SSJS Code
importPackage(com.nnsu.domino);
var jce:DomSession1 = new DomSession1();
var retOutput = jce.getOutput(session);
getComponent("computedField1").setValue(retOutput);

– The Java Code
import lotus.domino.Session;
public class DomSession1 {
private StringBuffer output = new
StringBuffer();
// global session object passed as parameter
in the method call
public String getOutput(Session session) {
try {
output.append("The Notes version is: " +
session.getNotesVersion() + nl);
62
Session

• Get it from the JSF “context”, the underlying
architecture
import javax.faces.context.FacesContext;
import lotus.domino.Session;
public class DomSession2 {
private StringBuffer output = new StringBuffer();
private String nl = "<br />";
// global session object passed as parameter in the method call
public String getOutput() {
FacesContext context = FacesContext.getCurrentInstance();
Session session = (Session)
context.getApplication().getVariableResolver().resolveVariable(
context, "session");
…}

63
Session

• Once there is a “session” object, the rest of the Domino
class hierarchy can be traversed
– Database
– View
– ViewNavigator
– Document
– Item
– DocumentCollection
– Etc…

64
Demo: Domino Objects

65
Agenda

• The Java Language Fundamentals
• Domino Designer Settings
• Java Beans and Managed Beans
• Calling Java Code from an XPage
• Using the Expression Language
• Accessing Domino Objects
• Using Third Party Libraries
• Wrap Up

66
Development Setup

• There are two choices when configuring an
application to use third party Java libraries
– Put all the JARS in the NSF
– Put the JARS on the Host File System

67
Put all the JARS in the NSF

• Pros

– Makes the application more portable.
– Can be “deployed” to the test server and production by
replication

• Cons

– JARS are only accessible by code in the containing NSF
– If many NSF’s use this solution then maintenance can
become difficult

• Going from version “x” to version “y” has to be done in every
application

68
Put the JARS on Host File System

• Pros
– Easier to maintain code/upgrade code for all
applications that use it
• Cons
– Harder to deploy (insert snarky Evil Admin
comment here)

69
Development Setup

• I prefer to deploy the JARS to the Host File system
– (Insert self referencing Evil Admin Comment here)
– If the code that CALLS the classes from the JARS is:

• A Java Agent, Servlet, Java Class or Java Code Element (available in 8.5.3
and above)
- Deploy the JARS to the <installDir>/jvm/lib/ext folder

• SSJS Code from an XPage

- Deploy the JARS to the <installDir>/xsp folder

– JARS will have to be deployed to the Notes Designer Client
AND the development/production servers !!
– If the Client or Server is running restart in order for your
code to recognize that they are there
• This is the step you will forget. Just sayin’

70
Development Setup

• The JARS can also be added to the NSF container
when developing XPages.
– This is the option I’m using so you have a self
contained demonstration/example system you
can play with locally or on a TEST Server.

71
Development Setup

• In 8.5.3 and below
– In the Application that will contain the XPage Code
• From the XPages perspective switch to the Package Explorer View
• Expand the WebContent/WEB-INF folder
- Create a folder named “lib”
• Import (you can also drag and drop)
the JARS to the lib folder

72
Development Setup

• In 9.0
– Import the Jars to the new “JAR” design element
– This will automatically add it to the class/build path
• No other configuration is required

73
Third Party Libraries

• Third party libraries can come from a variety of sources
– Open Source
– Purchased from vendors

• A “solution” to a particular coding problem not available in
the host system API
– “I need to parse a String object at every capitalized letter”
– “I need to export all my data to a spreadsheet”
– “I need to create a PDF from this data”

• One of the “Go To” solutions for tested, reliable Java
Libraries is the Apache Software Foundation

74
What is APACHE ?

• The Apache Software Foundation
(www.apache.org)
– Open Source (Yes that means FREE) consortium of
companies and developers
– Donates time and resources to developing tools
(primarily Java based) that simplify many tasks that
developers are faced with everyday
– Like OpenNTF, but for Java developers

75
What is APACHE ?

• IBM is a major contributor/supporter
• If you develop using Java code (and you should be)
review the projects on this site
• Some I use all the time:
–
–
–
–
–

Xerces
Xalan
XML Graphics (FOP)
POI
Commons

76
Apache Commons

• http://commons.apache.org
• Focused on all aspects of reusable Java components

77
Commons Proper

• Commons Proper
– Goal of creating and maintaining reusable java
Components

• Individual downloadable components
– Not one GIANT utility library
– Just get what you need

78
Commons Proper

• Each of the following components can be downloaded
individually
Component
Attributes
BCEL

Betwixt
BSF

BeanUtils
Chain
CLI
Codec

Collections
Compress
Configuration
CSV
Daemon
DBCP
DbUtils
Digester

Runtime API to metadata attributes such as doclet tags.
Byte Code Engineering Library - analyze, create, and manipulate Java class
files
Easy-to-use wrappers around the Java reflection and introspection APIs.
Services for mapping JavaBeans to XML documents, and vice versa.
Bean Scripting Framework - interface to scripting languages, including
JSR-223
Chain of Responsibility pattern implemention.
Command Line arguments parser.
General encoding/decoding algorithms (for example phonetic, base64,
URL).
Extends or augments the Java Collections Framework.
Defines an API for working with tar, zip and bzip2 files.
Reading of configuration/preferences files in various formats.
Component for reading and writing comma separated value files.
Alternative invocation mechanism for unix-daemon-like java code.
Database connection pooling services.
JDBC helper library.
XML-to-Java-object mapping utility.

79
Commons Proper

Component
Discovery

Tools for locating resources by mapping service/reference names to resource names.

EL

Interpreter for the Expression Language defined by the JSP 2.0 specification.

Email

Library for sending e-mail from Java.

Exec

API for dealing with external process execution and environment management in Java.

FileUpload

File upload capability for your servlets and web applications.

Functor

A functor is a function that can be manipulated as an object, or an object representing a
single, generic function.
A pure-Java image library.

Imaging (previously called
Sanselan)
IO

Collection of I/O utilities.

JCI

Java Compiler Interface

JCS

Java Caching System

Jelly

XML based scripting and processing engine.

Jexl

Expression language which extends the Expression Language of the JSTL.

JXPath

Utilities for manipulating Java Beans using the XPath syntax.

Lang

Provides extra functionality for classes in java.lang.

80
Commons Proper

Component
Launcher

Cross platform Java application launcher.

Logging

Wrapper around a variety of logging API implementations.

Math

Lightweight, self-contained mathematics and statistics components.

Modeler

Mechanisms to create Model MBeans compatible with JMX specification.

Net

Collection of network utilities and protocol implementations.

OGNL

An Object-Graph Navigation Language

Pool

Generic object pooling component.

Primitives

Smaller, faster and easier to work with types supporting Java primitive types.

Proxy

Library for creating dynamic proxies.

SCXML

Transaction

An implementation of the State Chart XML specification aimed at creating and maintaining a Java
SCXML engine. It is capable of executing a state machine defined using a SCXML document, and
abstracts out the environment interfaces.
Implementations for multi level locks, transactional collections and transactional file access.

Validator

Framework to define validators and validation rules in an xml file.

VFS

Virtual File System component for treating files, FTP, SMB, ZIP and such like as a single logical file
system.

81
Commons Lang

• Provides a host of helper utilities for the java.lang
API
–
–
–
–

String manipulation methods
Basic numerical methods
Object reflection
Additionally it contains basic enhancements to
java.util.Date

82
Commons Lang - Versions

• Latest Version is 3.3.1
– For Java 1.5 and higher
– For Notes/Domino 8.x and 9.x

• Version 2.6 is still available
– For Java 1.2 and higher
– For Notes Domino 7.x and below
http://commons.apache.org/proper/commons-lang/download_lang.cgi

83
Commons Lang API

Packages
org.apache.commons.lang3

Provides highly reusable static utility methods, chiefly concerned with adding value to
the java.lang classes.

org.apache.commons.lang3.builder

Assists in creating consistent equals(Object), toString(), hashCode(),
and compareTo(Object) methods.

org.apache.commons.lang3.concurrent

Provides support classes for multi-threaded programming.

org.apache.commons.lang3.event

Provides some useful event-based utilities.

org.apache.commons.lang3.exception

Provides functionality for Exceptions.

org.apache.commons.lang3.math

Extends java.math for business mathematical classes.

org.apache.commons.lang3.mutable

Provides typed mutable wrappers to primitive values and Object.

org.apache.commons.lang3.reflect

Accumulates common high-level uses of the java.lang.reflect APIs.

org.apache.commons.lang3.text

Provides classes for handling and manipulating text, partly as an extension to java.text.

org.apache.commons.lang3.text.translate

An API for creating text translation routines from a set of smaller building blocks.

org.apache.commons.lang3.time

Provides classes and methods to work with dates and durations.

org.apache.commons.lang3.tuple

Tuple classes, starting with a Pair class in version 3.0.

84
org.apache.commons.lang3.StringUtils

•
•
•
•
•
•
•

IsEmpty/IsBlank - checks if a String contains text
Trim/Strip - removes leading and trailing whitespace
Equals - compares two strings null-safe
startsWith - check if a String starts with a prefix null-safe
endsWith - check if a String ends with a suffix null-safe
IndexOf/LastIndexOf/Contains - null-safe index-of checks
IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut
- index-of any of a set of Strings

85
org.apache.commons.lang3.StringUtils

• ContainsOnly/ContainsNone/ContainsAny - does String contains
only/none/any of these characters
• Substring/Left/Right/Mid - null-safe substring extractions
• SubstringBefore/SubstringAfter/SubstringBetween - substring
extraction relative to other strings
• Split/Join - splits a String into an array of substrings and vice
versa
• Remove/Delete - removes part of a String
• Replace/Overlay - Searches a String and replaces one String with
another

86
org.apache.commons.lang3.StringUtils

• Chomp/Chop - removes the last part of a String
• LeftPad/RightPad/Center/Repeat - pads a String
• UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize changes the case of a String
• CountMatches - counts the number of occurrences of one String
in another

87
org.apache.commons.lang3.StringUtils

• IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the
characters in a String
• DefaultString - protects against a null input String
• Reverse/ReverseDelimited - reverses a String
• Abbreviate - abbreviates a string using ellipsis
• Difference - compares Strings and reports on their differences
• LevenshteinDistance - the number of changes needed to
change one String into another

88
Demo: Commons StringUtils

89
Resources

• IBM XPages Forum – Moderated by the community
– http://www-10.lotus.com/ldd/xpagesforum.nsf/

• TLCC – Self paced Courses on XPages and Java
– http://www.tlcc.com

 NetNotes Solutions Unlimited - My Web Site
 http://www.nnsu.com

• Apache Software Foundation
– http://www.apache.org

• OpenNTF

– http://www.openntf.org

• XPages Tips

– http://xpagetips.blogspot.com

90
Questions????

Use the Q&A pane in WebEx
to ask questions
We will answer your questions
verbally

91
Question and Answer Time!

Paul Calhoun

Paul Della-Nebbia

Howard Greenberg

Download the demo - http://www.tlcc.com/java-webinar
Upcoming Events:

TLCC Connect Sale
IBM Connect 2014 Registration is still open
Be sure to attend our sessions!
Visit Teamstudio in booth 114

TLCC Questions?

howardg@tlcc.com paul@tlcc.com
888-241-8522 or 561-953-0095

Courtney Carter

#XPages
@ptcalhoun
@TLCCLtd
@Teamstudio
@PaulDN

Teamstudio Questions?
contactus@teamstudio.com
877-228-6178

92

More Related Content

PDF
そろそろ知っておきたい!!コンテナ技術と Dockerのキホン
PDF
ZOZOTOWNのCloud Native Journey
PDF
OSS+AWSでここまでできるDevSecOps (Security-JAWS第24回)
PDF
Redmineのチケット分類例
PDF
Active Directory のおさらいをしましょう!~グループポリシー編~
PDF
今さら聞けない!Active Directoryドメインサービス入門
PDF
おさらいActive directory 130330
PPTX
SCUGJ第27回勉強会:ものすごくざっくりなAzure Filesの話
そろそろ知っておきたい!!コンテナ技術と Dockerのキホン
ZOZOTOWNのCloud Native Journey
OSS+AWSでここまでできるDevSecOps (Security-JAWS第24回)
Redmineのチケット分類例
Active Directory のおさらいをしましょう!~グループポリシー編~
今さら聞けない!Active Directoryドメインサービス入門
おさらいActive directory 130330
SCUGJ第27回勉強会:ものすごくざっくりなAzure Filesの話

What's hot (20)

PDF
フロントからバックエンドまで - WebAssemblyで広がる可能性
 
PDF
Happy Windows Automation with Ansible
PPTX
今さら聞けない! Active Directoryドメインサービス入門
PDF
Docker 基本のおさらい
PDF
Vue.js で XSS
PDF
行ロックと「LOG: process 12345 still waiting for ShareLock on transaction 710 afte...
PDF
Active Directory をInternetから使用するための4つのシナリオ
PDF
M04_失敗しないための Azure Virtual Desktop 設計ガイド
PDF
Apache Bigtop3.2 (仮)(Open Source Conference 2022 Online/Hiroshima 発表資料)
PPTX
イケてない開発チームがイケてる開発を始めようとする軌跡
PPTX
OpenStackで始めるクラウド環境構築入門
PPTX
PHP と SAPI と ZendEngine3 と
PPTX
OpenStack Glance
PDF
Fluentdのお勧めシステム構成パターン
PDF
PodSecurityPolicy からGatekeeper に移行しました / Kubernetes Meetup Tokyo #57
PPTX
[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)
PDF
Ansibleで始めるインフラ構築自動化
PDF
【メモ】一般的に設計書に定義される項目例
PDF
「これからはじめるNGINX技術解説~基本編」セミナー (NGINX Back to Basic in JP)
PPTX
VMware ESXi 6.0 Installation Process
フロントからバックエンドまで - WebAssemblyで広がる可能性
 
Happy Windows Automation with Ansible
今さら聞けない! Active Directoryドメインサービス入門
Docker 基本のおさらい
Vue.js で XSS
行ロックと「LOG: process 12345 still waiting for ShareLock on transaction 710 afte...
Active Directory をInternetから使用するための4つのシナリオ
M04_失敗しないための Azure Virtual Desktop 設計ガイド
Apache Bigtop3.2 (仮)(Open Source Conference 2022 Online/Hiroshima 発表資料)
イケてない開発チームがイケてる開発を始めようとする軌跡
OpenStackで始めるクラウド環境構築入門
PHP と SAPI と ZendEngine3 と
OpenStack Glance
Fluentdのお勧めシステム構成パターン
PodSecurityPolicy からGatekeeper に移行しました / Kubernetes Meetup Tokyo #57
[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)
Ansibleで始めるインフラ構築自動化
【メモ】一般的に設計書に定義される項目例
「これからはじめるNGINX技術解説~基本編」セミナー (NGINX Back to Basic in JP)
VMware ESXi 6.0 Installation Process
Ad

Viewers also liked (19)

PDF
Access Data from XPages with the Relational Controls
PDF
Connect 2014 JMP101: Java for XPages Development
PDF
Tips for Building your First XPages Java Application
PPTX
How to upload a file to an IBM Connections.Cloud Community using the Plugins ...
PPTX
How to share a File using IBM Connections.Cloud
PPTX
Bootstrap4XPages webinar
PPTX
XPages and Java (DanNotes 50th conference, November 2013)
PDF
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
PDF
SHOW107: The DataSource Session: Take XPages data boldly where no XPages data...
PDF
xe:objectData
ODP
IBM Domino Designer: Tips and tricks for maximum productivity
PDF
BP110: The Mobile Distruption - Why XPages Development is targeting Mobile First
PDF
IBM Collaboration Solutions Community Meeting 11/11 - OpenNTF
PDF
Aveedo - Your application framework
PPTX
Entwicklercamp responive web design
PDF
Domino OSGi Development
PDF
Optimus XPages: An Explosion of Techniques and Best Practices
PPT
Keynote apertura Dominopoint Days 2013, #dd13
PDF
ICONUK 2013 - An XPager's Guide to Process Server-Side Jobs on IBM® Domino®
Access Data from XPages with the Relational Controls
Connect 2014 JMP101: Java for XPages Development
Tips for Building your First XPages Java Application
How to upload a file to an IBM Connections.Cloud Community using the Plugins ...
How to share a File using IBM Connections.Cloud
Bootstrap4XPages webinar
XPages and Java (DanNotes 50th conference, November 2013)
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
SHOW107: The DataSource Session: Take XPages data boldly where no XPages data...
xe:objectData
IBM Domino Designer: Tips and tricks for maximum productivity
BP110: The Mobile Distruption - Why XPages Development is targeting Mobile First
IBM Collaboration Solutions Community Meeting 11/11 - OpenNTF
Aveedo - Your application framework
Entwicklercamp responive web design
Domino OSGi Development
Optimus XPages: An Explosion of Techniques and Best Practices
Keynote apertura Dominopoint Days 2013, #dd13
ICONUK 2013 - An XPager's Guide to Process Server-Side Jobs on IBM® Domino®
Ad

Similar to Java for XPages Development (20)

PDF
A Notes Developer's Journey into Java
DOCX
PDF
XPages Blast - Lotusphere 2013
PDF
XPages Blast - Ideas, Tips and More
PDF
X pages jumpstart jmp101
PDF
SHOW102 XPages: Still No Experience Necessary IBM Connect 2014
PDF
Harness the power of XPages in Lotus Domino
PDF
Connect 2014 SHOW102: XPages Still No Experience Necessary
PDF
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
PPT
Domino java
PPTX
Get the Jump on Mobilizing your Notes and Domino Applications Today! (JMP103...
PDF
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
PDF
An Introduction to the Model-View-Controller Pattern
PDF
We4IT lcty 2013 - infra-man - whats new in ibm domino application development
PPTX
Bccon use notes objects in memory and other useful
PDF
Developing XPages Applications
PDF
From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...
PDF
We4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshell
PDF
Icsug conf 14_dev04_ibm_domino_apps_reaching_up_out
PPTX
Engage 2019 - De04. Java with Domino After XPages
A Notes Developer's Journey into Java
XPages Blast - Lotusphere 2013
XPages Blast - Ideas, Tips and More
X pages jumpstart jmp101
SHOW102 XPages: Still No Experience Necessary IBM Connect 2014
Harness the power of XPages in Lotus Domino
Connect 2014 SHOW102: XPages Still No Experience Necessary
The Autobahn Has No Speed Limit - Your XPages Shouldn't Either!
Domino java
Get the Jump on Mobilizing your Notes and Domino Applications Today! (JMP103...
JMP402 Master Class: Managed beans and XPages: Your Time Is Now
An Introduction to the Model-View-Controller Pattern
We4IT lcty 2013 - infra-man - whats new in ibm domino application development
Bccon use notes objects in memory and other useful
Developing XPages Applications
From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...
We4IT LCTY 2013 - x-pages-men - ibm domino xpages - performance in a nutshell
Icsug conf 14_dev04_ibm_domino_apps_reaching_up_out
Engage 2019 - De04. Java with Domino After XPages

More from Teamstudio (20)

PDF
Search Terms and Design Complexity: A Tutorial Before Modernizing or Migrating
PDF
SmartNSF - 100% Smart - and in Color!
PDF
Back from the Dead: When Bad Code Kills a Good Server
PDF
Understand Usage with Detailed Access Information
PDF
IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8
PDF
Marty, You're Just Not Thinking Fourth Dimensionally
PDF
IBM Presents the IBM Notes and Domino Roadmap
PDF
XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...
PDF
Take a Trip Into the Forest: A Java Primer on Maps, Trees, and Collections
PDF
Expanding XPages with Bootstrap Plugins for Ultimate Usability
PDF
Optimus XPages Part 2: The Deep Dive
PDF
Getting Started with the OpenNTF Domino API
PPTX
Understand the True Business Usage of Notes Applications with Usage Auditor
PDF
Building Responsive Applications Using XPages
PDF
Using Cool New Frameworks in (Mobile) Domino Apps
PDF
Ask the XPages Experts
PDF
Everything XControls
PDF
Move Your XPages Applications to the Fast Lane
PDF
Mobilisez vos Applications IBM Notes avec Teamstudio Unplugged ! (French Lang...
PDF
Domino, Notes, and Verse - Where are We and Whats the Future?
Search Terms and Design Complexity: A Tutorial Before Modernizing or Migrating
SmartNSF - 100% Smart - and in Color!
Back from the Dead: When Bad Code Kills a Good Server
Understand Usage with Detailed Access Information
IBM Presents the Notes Domino Roadmap and a Deep Dive into Feature Pack 8
Marty, You're Just Not Thinking Fourth Dimensionally
IBM Presents the IBM Notes and Domino Roadmap
XPages and jQuery DataTables: Simplifying View Creation while Maximizing Func...
Take a Trip Into the Forest: A Java Primer on Maps, Trees, and Collections
Expanding XPages with Bootstrap Plugins for Ultimate Usability
Optimus XPages Part 2: The Deep Dive
Getting Started with the OpenNTF Domino API
Understand the True Business Usage of Notes Applications with Usage Auditor
Building Responsive Applications Using XPages
Using Cool New Frameworks in (Mobile) Domino Apps
Ask the XPages Experts
Everything XControls
Move Your XPages Applications to the Fast Lane
Mobilisez vos Applications IBM Notes avec Teamstudio Unplugged ! (French Lang...
Domino, Notes, and Verse - Where are We and Whats the Future?

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
KodekX | Application Modernization Development
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PPT
Teaching material agriculture food technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
KodekX | Application Modernization Development
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
Unlocking AI with Model Context Protocol (MCP)
sap open course for s4hana steps from ECC to s4
Understanding_Digital_Forensics_Presentation.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Teaching material agriculture food technology
Encapsulation_ Review paper, used for researhc scholars
Network Security Unit 5.pdf for BCA BBA.
Building Integrated photovoltaic BIPV_UPV.pdf

Java for XPages Development

  • 1. Java for XPages Development Tweet about this event: #XPages and mention us: @teamstudio @TLCCLTD @PaulDN @ptcalhoun January 16, 2014
  • 3. Who We Are • Our background is in creating tools for collaborative computing in mid-size and large enterprises, primarily for IBM Notes • Easy-to-use tools for developers and administrators • 2300+ active customers, 47 countries • Offices in US, UK and Japan • Entered mobile space in 2010 with Unplugged: easy mobilization of Notes apps to Blackberry, Android and iOS
  • 4. Teamstudio Unplugged • Your mobile Domino server: take your Notes apps with you! • End-users access Notes applications from mobile devices whether online or offline • Leverages existing skills and technology – XPages – a replication model you already know • Unplugged 3.0 recently released • IBM Collaboration Solutions Award Winner 2013
  • 5. Unplugged Templates • Continuity – Mobile offline access to BCM programs • OneView Approvals – Expense approvals; anywhere, anytime • CustomerView – lightweight CRM framework for field sales and field service teams • Contacts – customer information database • Activities – customer activity log • Media – mobile offline file storage and access
  • 6. • Next Teamstudio/TLCC webinar: February 13, 2014 • Next Wireless Wednesdays webinar: Part 2 on March 5, 2014 o Learn Domino mobile development • IBM Connect: booth 114; Mobile Made Easy session • Promotion: o Get 20% off your order of 25+ licenses of Unplugged
  • 7. Java in XPages Development Your Host Today: Howard Greenberg TLCC @TLCCLtd #XPages 1
  • 8. Upcoming and Recorded Webinars Next Webinar – February 13th Creating a Great XPages User Interface with Howard and Paul www.tlcc.com/xpages-webinar View Previous Webinars (use url above) 2
  • 9. Session Date JMP101: Java for XPages Development with Paul Calhoun Sunday at 10:30 JMP102: Creating a Great XPages User Interface with Howard and Paul D. Sunday at 1:30 SHOW102: XPages: Still No Experience Necessary with Paul Calhoun and Kathy Brown Wednesday at 10:30 BP202: Rapid XPages Development Using the Application Layout Control with Howard and Paul D. Thursday at 11:15 Click here for more information and to signup 3
  • 10. TLCC Courses and Services • The Leader in Notes and Domino Training since 1997 • Self Paced Distance Learning Courses for Notes/Domino – XPages, Development, and Administration (user too!) • OnSite Private Classes • TLCC Mentoring Services • Free demo courses – Intro. To XPages Development – Application Development 1 4
  • 11. • Save hundreds and even Thousands of Dollars on the most popular courses and packages • Through January 31st • No need to attend Connect  But if you do, all certification tests are free!  TLCC’s courses will help you get ready for the exams Click here for more information 5
  • 12. New TLCC Java Courses and Package • Java 2 for XPages Development (9.0) • • • • Debugging Expression Language JavaBeans and Managed Beans Third Party Java Libraries – On Sale for $599, save $300 • Java 1 for XPages Development (9.0) – Covers the Java Language • Java for XPages Package (Domino 9) – Has both Java courses – On Sale for only $999, save $500 – Until January 31st Only 6
  • 13. Asking Questions Q & A at the end! Type in your questions as they come up 7
  • 14. Your Presenters Today: Paul Calhoun NetNotes Solutions @ptcalhoun Paul Della-Nebbia TLCC @PaulDN #XPages 8
  • 15. Agenda • The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up 9
  • 16. How do you eat an Elephant ? • One Bite at a time !!! • Learning Java™ is a lot like eating an Elephant !! – It’s a big job !! – And there’s no clear place where to start !! 10
  • 17. Resources … • TLCC Courses – Rapid XPages Development – Java 1 for XPages Development – Java 2 for XPages Development • http://www.tlcc.com/admin/tlccsite.nsf/DeveloperView.xsp 11
  • 18. Resources … • Start with J2SE (Java 2 STANDARD Edition) – This covers core Java functionality • Syntax • Data Types • Constructs • Core Classes - java.lang - java.io - java.net - etc. – Allow 3-6 Months http://www.oracle.com/technetwork/java/javase/overview/index.html 12
  • 19. Resources • Learn XML (not part of Sun Certification) – XML Syntax – DTD/XML Schema – XSL • XSLT • XSL:FO • Finally jump on the J2E bandwagon (In this order!) – Servlets – JSPs – JSFs – Allow another 3-6 months • Then the rest of the J2E specification – Allow another 3-6 months 13
  • 20. Roadblocks • Road Blocks on your Journey to Learning Java – “Linear” thinking instead of thinking in “Objects” • If you have done any LotusScript Class development you are on your way ! – Starting to learn Java with J2E applications (Servlets, JSPs) – Trying to start with the Java Enterprise Technologies – Try to learn Java in conjunction with a HUGE Mission critical project – Not applying what you learn EVERYDAY !! • This is the MOST critical roadblock !!! 14
  • 21. Very Wise Saying “If the only tool you have is a hammer, you tend to see every problem as a nail” Abraham Maslow 15
  • 22. Your XPages Development Toolbox Formula Language CSS LotusScript XML dojo Java JavaScript XSLT jQuery 16
  • 23. Is the Java Language still relevant ? • The Tiobe index as of December 2013 http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html 17
  • 24. Java Version in Notes / Domino Java Standard Edition (J2SE) Java 2 Java Development Kit (JDK) Version 6.0 Used in Notes Domino 9.0 and 8.5 Java 2 Java Development Kit (JDK) Version 1.5.0 Used in Notes Domino 8 Java 2 Software Development Kit (SDK) Version 1.4.2 Used in Notes Domino 7 Java 2 Software Development Kit (SDK) Version 1.4.1 (EOL) Java 2 Software Development Kit (SDK) Version 1.4.0 (EOL) Java 2 Software Development Kit (SDK) Version 1.3.1 Used in Notes Domino 6 Java 2 Software Development Kit (SDK) Version 1.3.0 (EOL) Java 2 Software Development Kit (SDK) Version 1.2.2 Java 1 JDK Development Kit (JDK) Version 1.1.8 Used in Notes Domino 5 18
  • 25. Agenda • The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up 19
  • 26. Configure DDE for XPage Development • There are several things that can be configured that will make your Java in XPages development experience easier • The following are recommendations for setting properties in the Domino Designer BEFORE you start developing 20
  • 27. Configure Memory • Change your memory allocation – Edit the jvm.properties file located in the client installation directory under • framework/rcp/deploy 21
  • 28. Configure Memory • Edit with any text editor – Xmx – Total amount of RAM for Designer AND Client • Set to at least 512m • Don’t set equal to the amount of system RAM – Xms – Starting Heap size • Set to at least 128m • Don’t set equal to Xmx value – Xmca – Memory block size • Set to at least 512k • That’s a “k” NOT A “m” • Always set in multiple of “4” • Will not take effect until client is restarted (if running when edited) 22
  • 29. Show Heap • Monitor Memory Used • In Designer Preferences – Select General – Check “Show heap status” • Even though this is a checkbox, it does not “remember” the setting. – It has to be checked each time you start Designer • Heap status in the lower left hand corner of Designer – Monitor the amount of memory being used – Click the trash can icon to trigger garbage collection 23
  • 30. Configure XML Editor • Set XML Editor formatting for viewing XPage source • In Designer preferences – Select XML | XML Files | Editor – Change Line width – Check “Split multiple attributes each on a new line” – Check “Clear all blank lines” • Any new XPages source will adhere to these settings • Existing XPages can be reformatted” – keyboard shortcut is <shift><ctrl><f> 24
  • 31. Formatting Differences • Before and after XPage Source Formatting 25
  • 32. Java Editor Margin • In the Designer Preferences dialog, choose: Java > Code Style > Formatter – Click the “New” button – The included profiles can not be edited 26
  • 33. Change Java Editor Margin • Select the “Line Wrapping” tab – Change the “Maximum line width:” property to at least 120 27
  • 34. Change Java Editor Margin • Ensure your profile is the active profile and save preferences 28
  • 35. Agenda • The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up 29
  • 36. Java Beans vs Managed Beans • One of the most confusing issues when coding with Java • A Java Bean is a Plain ‘ol Java Object (POJO) or Java class that conforms to a specific programming convention – Must have a public no-argument constructor, otherwise the default no argument constructor is used – Class properties (fields) must be defined as private and accessible using standard public method calls • Start with get, set, or is (used for boolean properties instead of get) • Commonly referred to as "getter" and "setter" methods – The class must implement java.io.Serializable to be technically qualified as a JavaBean. • This is not “necessary” but a best practice • Up to the developer to follow these conventions when creating a JavaBean 30
  • 37. Java Beans vs Managed Beans • So what is a Managed Bean? • It is important to understand that it makes no difference if a bean is going to be just a Java Bean or a Managed Bean, it is coded the exact same way – Nothing in the Java source code defines it as a "Managed Bean” – This is all done in the framework, in our case, XPages • Java Beans are NOT Managed Beans – But they can be, they just need to be "managed” – A Managed Bean follows all of the same conventions as a regular JavaBean, but is "Managed" by virtue of being registered with the framework it is incorporated in (like the XPages runtime framework) – A Managed Bean has scope in the framework and its methods can be called directly without the need to first instantiate an object variable for the Managed Bean • This is the PRIMARY factor that separates Java Beans from Managed Beans 31
  • 38. A Java Bean Example • Lets start with a simple Java Bean Example 32
  • 39. A Java Bean Example • Public “getter” and “setters” 33
  • 40. Calling the Methods from an XPage • Button Code – The SSJS Code – In order to “use” the Java Bean Code it has to be instantiated (lines 1&2) – The public getter and setter methods have to be called importPackage(com.nnsu.beans); var jce:MyBean = new MyBean(); jce.setFName("Paul"); jce.setLName("Calhoun"); jce.setAge(50); jce.setHobbies(new java.util.ArrayList(java.util.Arrays.asList(["Riding Motorcycles","Playing with Grandkids"]))); var retOutput = jce.getFName()+ " "+ jce.getLName()+"</br>"; retOutput += "He is: " + jce.getAge()+"</br>"; for (var i=0;i<jce.getHobbies().size();i++) { retOutput += jce.getHobbies().get(i) +"</br>"; } getComponent("computedField1").setValue(retOutput); 34
  • 41. Demo: A Java Bean 35
  • 42. Making a “Managed Bean”from the same code • Java code becomes a “Managed Bean” when it is registered with the framework it is running in (In our case XPages) • Managed Beans are “Registered” in the faces-config.xml file in the application they will be used in 36
  • 43. Faces Config • The faces-config.xml file is an xml file where managed beans are defined using the following syntax: <managed-bean> <description>description</description> <managed-bean-name>beanName</managed-bean-name> <managed-bean-class>beanClass</managed-bean-class> <managed-bean-scope>beanScope</managed-bean-scope> </managed-bean> • To “Register” the previous bean as a “Managed Bean” the syntax would be: <managed-bean> <description>My Managed Bean</description> <managed-bean-name>myBean</managed-bean-name> <managed-beanclass>com.nnsu.beans.MyBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> 37
  • 44. Registration components • The description is just that, a short description of what the bean does • The name will be the programmatic name the bean is instantiated with • The class is the full class path to the code in the application • The scope is the “life” of the Managed Bean which can be: – application - The bean is available for as long as the application is in memory and is shared among all users of the application. – session - The bean is available for the current user session and is unique for each user. – view - The bean is available for the life of the current "view" or XPage. – request - The bean is available only while the content of the individual XPage is being submitted. – none - The bean is instantiated each time it is referenced. This is helpful if the bean is referenced within another bean. 38
  • 45. Calling the Methods from an XPage • Button Code – The SSJS Code – To “use” the Managed Bean Code call the methods using the defined bean name the code was registered with in the facesconfig.xml 39
  • 46. Calling the Methods from an XPage • Button Code – Notice that the Bean is never instantiated. This is because the framework (XPages) instantiates it when it is called the first time. myBean.setFName("Paul"); myBean.setLName("Calhoun"); myBean.setAge(50); myBean.setHobbies(new java.util.ArrayList(java.util.Arrays.asList(["Riding Motorcycles","Playing with Grandkids"]))); var retOutput = myBean.getFName()+ " "+ myBean.getLName()+"</br>"; retOutput += "He is: " + myBean.getAge()+"</br>"; for (var i=0;i<myBean.getHobbies().size();i++) { retOutput += myBean.getHobbies().get(i) +"</br>"; } getComponent("computedField1").setValue(retOutput); 40
  • 47. Benefits of Managed Bean • Managed Beans have scope – The setter methods can be executed in one event and – The getter methods executed in another event – The methods of the managed bean can be used across multiple pages in the same application • So should Java Beans ALWAYS be Managed Beans?? – As a rule, NO !!! – Only use Managed Beans when you need the values in the bean to “persist” in your application – If persistence is not required then just use POJO’s 41
  • 49. Agenda • The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up 43
  • 50. Executing Java Code • The only Java code that can be “called” from an XPage is: – Java Code Elements – Java Source Code in a source folders in the Virtual File System (VFS) • Primarily prior to 9.0 – Code in .jar files located in the JARs folder – Code in .jar files located in the WebContent/WEB-INF/lib folder – Compiled .class and .jar files located in the jvm/lib/ext folder in the file system 44
  • 51. Java Code Elements • Create Java source code that will be compiled into individual class files when the project is built • Java Code elements are automatically added to the classpath 45
  • 52. Source code in source folders • Java Source code located in a Java Source folder in the VFS can be seen in the “Package Explorer” view of the XPages perspective • Java Code in a “source” folder is automatically added to the classpath 46
  • 53. Code in .jar files in the JARS design folder • Locally developed or third party Java Archive Files (.jar) can be imported into the Jar design element • Classed in JAR elements are automatically added to the classpath 47
  • 54. Compiled .class and .jar in jvm/lib/ext folder • .class and .jar files located in this folder are available to all applications running locally and on the server – GOTCHA: Java source files (.java) files in this folder will not compile and execute • Java Code located in this folder is automatically added to the classpath 48
  • 55. Calling Methods from SSJS • Java code is instantiated and called from a SSJS event – Import the Java package (unless the default package was used)(which is a VERY bad idea) – Instantiate an instance of a class from the imported package – Call a method from the instantiated class – “Do something” with the results or return a status message 49
  • 56. Demo: Calling Java code from SSJS 50
  • 57. Agenda • The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up 51
  • 58. Expression Language A scripting syntax in tag languages (JSP, JSF, XSP) to invoke the properties and methods of back end Java classes (specifically Java Beans). • begins with a # or $ character and is enclosed in curly brackets {} ${sessionScope.myVar} - evaluated once on page load #{sessionScope.myVar} - evaluated on page load, restore, renderResponse • must be written on a single line • evaluated from left to right … inner statements within the expression can be delimited using parenthesis for precedence • can concatenate several EL expressions to return a single string value … ${config.app.path}${config.app.custApp} • You can NOT nest an EL expression within another EL expression • An EL expression can return an object or value of any type 52
  • 59. Bracket and Dot Notation • Bracket notation: #{viewScope[“viewName”]} ${header[“User-Agent”]} • Dot notation: #{viewScope.viewName} ${header.User-Agent} • Can combine and chain expressions: ${facesContext["externalContext"]["requestServletPath"]} ${facesContext.externalContext["requestServletPath"]} ${facesContext.externalContext.requestServletPath} ${facesContext["externalContext"].requestServletPath} 53
  • 61. Use EL to … Bind Controls to Fields in a Data Source 55
  • 62. Use EL to … Get and Set Scoped Variables 56
  • 63. Use EL to … Get and Set Properties in JavaBeans 57
  • 64. Use EL to … Get and Set Properties in Managed Beans 58
  • 66. Agenda • The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up 60
  • 67. Session • The Notes Session object is the top level object in the Domino class hierarchy • The starting point for calling all other classes (database, view, etc) in the hierarchy • Two ways to get the session object in Java code executed from an XPage – Pass it in as a parameter from the SSJS – Get it from the JSF “context”, the underlying architecture 61
  • 68. Session • Pass the global “session” variable in as a parameter – The SSJS Code importPackage(com.nnsu.domino); var jce:DomSession1 = new DomSession1(); var retOutput = jce.getOutput(session); getComponent("computedField1").setValue(retOutput); – The Java Code import lotus.domino.Session; public class DomSession1 { private StringBuffer output = new StringBuffer(); // global session object passed as parameter in the method call public String getOutput(Session session) { try { output.append("The Notes version is: " + session.getNotesVersion() + nl); 62
  • 69. Session • Get it from the JSF “context”, the underlying architecture import javax.faces.context.FacesContext; import lotus.domino.Session; public class DomSession2 { private StringBuffer output = new StringBuffer(); private String nl = "<br />"; // global session object passed as parameter in the method call public String getOutput() { FacesContext context = FacesContext.getCurrentInstance(); Session session = (Session) context.getApplication().getVariableResolver().resolveVariable( context, "session"); …} 63
  • 70. Session • Once there is a “session” object, the rest of the Domino class hierarchy can be traversed – Database – View – ViewNavigator – Document – Item – DocumentCollection – Etc… 64
  • 72. Agenda • The Java Language Fundamentals • Domino Designer Settings • Java Beans and Managed Beans • Calling Java Code from an XPage • Using the Expression Language • Accessing Domino Objects • Using Third Party Libraries • Wrap Up 66
  • 73. Development Setup • There are two choices when configuring an application to use third party Java libraries – Put all the JARS in the NSF – Put the JARS on the Host File System 67
  • 74. Put all the JARS in the NSF • Pros – Makes the application more portable. – Can be “deployed” to the test server and production by replication • Cons – JARS are only accessible by code in the containing NSF – If many NSF’s use this solution then maintenance can become difficult • Going from version “x” to version “y” has to be done in every application 68
  • 75. Put the JARS on Host File System • Pros – Easier to maintain code/upgrade code for all applications that use it • Cons – Harder to deploy (insert snarky Evil Admin comment here) 69
  • 76. Development Setup • I prefer to deploy the JARS to the Host File system – (Insert self referencing Evil Admin Comment here) – If the code that CALLS the classes from the JARS is: • A Java Agent, Servlet, Java Class or Java Code Element (available in 8.5.3 and above) - Deploy the JARS to the <installDir>/jvm/lib/ext folder • SSJS Code from an XPage - Deploy the JARS to the <installDir>/xsp folder – JARS will have to be deployed to the Notes Designer Client AND the development/production servers !! – If the Client or Server is running restart in order for your code to recognize that they are there • This is the step you will forget. Just sayin’ 70
  • 77. Development Setup • The JARS can also be added to the NSF container when developing XPages. – This is the option I’m using so you have a self contained demonstration/example system you can play with locally or on a TEST Server. 71
  • 78. Development Setup • In 8.5.3 and below – In the Application that will contain the XPage Code • From the XPages perspective switch to the Package Explorer View • Expand the WebContent/WEB-INF folder - Create a folder named “lib” • Import (you can also drag and drop) the JARS to the lib folder 72
  • 79. Development Setup • In 9.0 – Import the Jars to the new “JAR” design element – This will automatically add it to the class/build path • No other configuration is required 73
  • 80. Third Party Libraries • Third party libraries can come from a variety of sources – Open Source – Purchased from vendors • A “solution” to a particular coding problem not available in the host system API – “I need to parse a String object at every capitalized letter” – “I need to export all my data to a spreadsheet” – “I need to create a PDF from this data” • One of the “Go To” solutions for tested, reliable Java Libraries is the Apache Software Foundation 74
  • 81. What is APACHE ? • The Apache Software Foundation (www.apache.org) – Open Source (Yes that means FREE) consortium of companies and developers – Donates time and resources to developing tools (primarily Java based) that simplify many tasks that developers are faced with everyday – Like OpenNTF, but for Java developers 75
  • 82. What is APACHE ? • IBM is a major contributor/supporter • If you develop using Java code (and you should be) review the projects on this site • Some I use all the time: – – – – – Xerces Xalan XML Graphics (FOP) POI Commons 76
  • 83. Apache Commons • http://commons.apache.org • Focused on all aspects of reusable Java components 77
  • 84. Commons Proper • Commons Proper – Goal of creating and maintaining reusable java Components • Individual downloadable components – Not one GIANT utility library – Just get what you need 78
  • 85. Commons Proper • Each of the following components can be downloaded individually Component Attributes BCEL Betwixt BSF BeanUtils Chain CLI Codec Collections Compress Configuration CSV Daemon DBCP DbUtils Digester Runtime API to metadata attributes such as doclet tags. Byte Code Engineering Library - analyze, create, and manipulate Java class files Easy-to-use wrappers around the Java reflection and introspection APIs. Services for mapping JavaBeans to XML documents, and vice versa. Bean Scripting Framework - interface to scripting languages, including JSR-223 Chain of Responsibility pattern implemention. Command Line arguments parser. General encoding/decoding algorithms (for example phonetic, base64, URL). Extends or augments the Java Collections Framework. Defines an API for working with tar, zip and bzip2 files. Reading of configuration/preferences files in various formats. Component for reading and writing comma separated value files. Alternative invocation mechanism for unix-daemon-like java code. Database connection pooling services. JDBC helper library. XML-to-Java-object mapping utility. 79
  • 86. Commons Proper Component Discovery Tools for locating resources by mapping service/reference names to resource names. EL Interpreter for the Expression Language defined by the JSP 2.0 specification. Email Library for sending e-mail from Java. Exec API for dealing with external process execution and environment management in Java. FileUpload File upload capability for your servlets and web applications. Functor A functor is a function that can be manipulated as an object, or an object representing a single, generic function. A pure-Java image library. Imaging (previously called Sanselan) IO Collection of I/O utilities. JCI Java Compiler Interface JCS Java Caching System Jelly XML based scripting and processing engine. Jexl Expression language which extends the Expression Language of the JSTL. JXPath Utilities for manipulating Java Beans using the XPath syntax. Lang Provides extra functionality for classes in java.lang. 80
  • 87. Commons Proper Component Launcher Cross platform Java application launcher. Logging Wrapper around a variety of logging API implementations. Math Lightweight, self-contained mathematics and statistics components. Modeler Mechanisms to create Model MBeans compatible with JMX specification. Net Collection of network utilities and protocol implementations. OGNL An Object-Graph Navigation Language Pool Generic object pooling component. Primitives Smaller, faster and easier to work with types supporting Java primitive types. Proxy Library for creating dynamic proxies. SCXML Transaction An implementation of the State Chart XML specification aimed at creating and maintaining a Java SCXML engine. It is capable of executing a state machine defined using a SCXML document, and abstracts out the environment interfaces. Implementations for multi level locks, transactional collections and transactional file access. Validator Framework to define validators and validation rules in an xml file. VFS Virtual File System component for treating files, FTP, SMB, ZIP and such like as a single logical file system. 81
  • 88. Commons Lang • Provides a host of helper utilities for the java.lang API – – – – String manipulation methods Basic numerical methods Object reflection Additionally it contains basic enhancements to java.util.Date 82
  • 89. Commons Lang - Versions • Latest Version is 3.3.1 – For Java 1.5 and higher – For Notes/Domino 8.x and 9.x • Version 2.6 is still available – For Java 1.2 and higher – For Notes Domino 7.x and below http://commons.apache.org/proper/commons-lang/download_lang.cgi 83
  • 90. Commons Lang API Packages org.apache.commons.lang3 Provides highly reusable static utility methods, chiefly concerned with adding value to the java.lang classes. org.apache.commons.lang3.builder Assists in creating consistent equals(Object), toString(), hashCode(), and compareTo(Object) methods. org.apache.commons.lang3.concurrent Provides support classes for multi-threaded programming. org.apache.commons.lang3.event Provides some useful event-based utilities. org.apache.commons.lang3.exception Provides functionality for Exceptions. org.apache.commons.lang3.math Extends java.math for business mathematical classes. org.apache.commons.lang3.mutable Provides typed mutable wrappers to primitive values and Object. org.apache.commons.lang3.reflect Accumulates common high-level uses of the java.lang.reflect APIs. org.apache.commons.lang3.text Provides classes for handling and manipulating text, partly as an extension to java.text. org.apache.commons.lang3.text.translate An API for creating text translation routines from a set of smaller building blocks. org.apache.commons.lang3.time Provides classes and methods to work with dates and durations. org.apache.commons.lang3.tuple Tuple classes, starting with a Pair class in version 3.0. 84
  • 91. org.apache.commons.lang3.StringUtils • • • • • • • IsEmpty/IsBlank - checks if a String contains text Trim/Strip - removes leading and trailing whitespace Equals - compares two strings null-safe startsWith - check if a String starts with a prefix null-safe endsWith - check if a String ends with a suffix null-safe IndexOf/LastIndexOf/Contains - null-safe index-of checks IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut - index-of any of a set of Strings 85
  • 92. org.apache.commons.lang3.StringUtils • ContainsOnly/ContainsNone/ContainsAny - does String contains only/none/any of these characters • Substring/Left/Right/Mid - null-safe substring extractions • SubstringBefore/SubstringAfter/SubstringBetween - substring extraction relative to other strings • Split/Join - splits a String into an array of substrings and vice versa • Remove/Delete - removes part of a String • Replace/Overlay - Searches a String and replaces one String with another 86
  • 93. org.apache.commons.lang3.StringUtils • Chomp/Chop - removes the last part of a String • LeftPad/RightPad/Center/Repeat - pads a String • UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize changes the case of a String • CountMatches - counts the number of occurrences of one String in another 87
  • 94. org.apache.commons.lang3.StringUtils • IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the characters in a String • DefaultString - protects against a null input String • Reverse/ReverseDelimited - reverses a String • Abbreviate - abbreviates a string using ellipsis • Difference - compares Strings and reports on their differences • LevenshteinDistance - the number of changes needed to change one String into another 88
  • 96. Resources • IBM XPages Forum – Moderated by the community – http://www-10.lotus.com/ldd/xpagesforum.nsf/ • TLCC – Self paced Courses on XPages and Java – http://www.tlcc.com  NetNotes Solutions Unlimited - My Web Site  http://www.nnsu.com • Apache Software Foundation – http://www.apache.org • OpenNTF – http://www.openntf.org • XPages Tips – http://xpagetips.blogspot.com 90
  • 97. Questions???? Use the Q&A pane in WebEx to ask questions We will answer your questions verbally 91
  • 98. Question and Answer Time! Paul Calhoun Paul Della-Nebbia Howard Greenberg Download the demo - http://www.tlcc.com/java-webinar Upcoming Events: TLCC Connect Sale IBM Connect 2014 Registration is still open Be sure to attend our sessions! Visit Teamstudio in booth 114 TLCC Questions? [email protected] [email protected] 888-241-8522 or 561-953-0095 Courtney Carter #XPages @ptcalhoun @TLCCLtd @Teamstudio @PaulDN Teamstudio Questions? [email protected] 877-228-6178 92