Java for XPages Development


Published on

Java is an important skill to have as an XPages developer. This webinar will provide a foundation of the Java skills you need and explain how to best acquire them. Come see how Java is used with detailed code examples that demonstrate how to use core Java code, Java Beans, Managed Beans, and third party Java libraries in your applications. After this webinar you will know exactly how to add Java as a tool in your development toolbox.

Published in: Technology

Java for XPages Development

  1. 1. Java for XPages Development Tweet about this event: #XPages and mention us: @teamstudio @TLCCLTD @PaulDN @ptcalhoun January 16, 2014
  2. 2. Courtney Carter @teamstudio Inbound Marketing Specialist @TLCCLTD
  3. 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. 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. 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. 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. 7. Java in XPages Development Your Host Today: Howard Greenberg TLCC @TLCCLtd #XPages 1
  8. 8. Upcoming and Recorded Webinars Next Webinar – February 13th Creating a Great XPages User Interface with Howard and Paul View Previous Webinars (use url above) 2
  9. 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. 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. 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. 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. 13. Asking Questions Q & A at the end! Type in your questions as they come up 7
  14. 14. Your Presenters Today: Paul Calhoun NetNotes Solutions @ptcalhoun Paul Della-Nebbia TLCC @PaulDN #XPages 8
  15. 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. 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. 17. Resources … • TLCC Courses – Rapid XPages Development – Java 1 for XPages Development – Java 2 for XPages Development • 11
  18. 18. Resources … • Start with J2SE (Java 2 STANDARD Edition) – This covers core Java functionality • Syntax • Data Types • Constructs • Core Classes - java.lang - - - etc. – Allow 3-6 Months 12
  19. 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. 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. 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. 22. Your XPages Development Toolbox Formula Language CSS LotusScript XML dojo Java JavaScript XSLT jQuery 16
  23. 23. Is the Java Language still relevant ? • The Tiobe index as of December 2013 17
  24. 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. 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. 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. 27. Configure Memory • Change your memory allocation – Edit the file located in the client installation directory under • framework/rcp/deploy 21
  28. 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. 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. 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. 31. Formatting Differences • Before and after XPage Source Formatting 25
  32. 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. 33. Change Java Editor Margin • Select the “Line Wrapping” tab – Change the “Maximum line width:” property to at least 120 27
  34. 34. Change Java Editor Margin • Ensure your profile is the active profile and save preferences 28
  35. 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. 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 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. 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. 38. A Java Bean Example • Lets start with a simple Java Bean Example 32
  39. 39. A Java Bean Example • Public “getter” and “setters” 33
  40. 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. 41. Demo: A Java Bean 35
  42. 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. 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. 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. 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. 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. 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
  48. 48. Demo: Managed Beans 42
  49. 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. 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. 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. 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. 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. 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. 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. 56. Demo: Calling Java code from SSJS 50
  57. 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. 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 … ${}${} • 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. 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
  60. 60. EL Operators 54
  61. 61. Use EL to … Bind Controls to Fields in a Data Source 55
  62. 62. Use EL to … Get and Set Scoped Variables 56
  63. 63. Use EL to … Get and Set Properties in JavaBeans 57
  64. 64. Use EL to … Get and Set Properties in Managed Beans 58
  65. 65. Demo: Domino Objects 59
  66. 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. 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. 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. 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. 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
  71. 71. Demo: Domino Objects 65
  72. 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. 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. 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. 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. 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. 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. 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. 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. 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. 81. What is APACHE ? • The Apache Software Foundation ( – 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. 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. 83. Apache Commons • • Focused on all aspects of reusable Java components 77
  84. 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. 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. 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. 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. 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. 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 83
  90. 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. 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. 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. 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. 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
  95. 95. Demo: Commons StringUtils 89
  96. 96. Resources • IBM XPages Forum – Moderated by the community – • TLCC – Self paced Courses on XPages and Java –  NetNotes Solutions Unlimited - My Web Site  • Apache Software Foundation – • OpenNTF – • XPages Tips – 90
  97. 97. Questions???? Use the Q&A pane in WebEx to ask questions We will answer your questions verbally 91
  98. 98. Question and Answer Time! Paul Calhoun Paul Della-Nebbia Howard Greenberg Download the demo - 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? 888-241-8522 or 561-953-0095 Courtney Carter #XPages @ptcalhoun @TLCCLtd @Teamstudio @PaulDN Teamstudio Questions? 877-228-6178 92
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.