BP118 Using Java to build applications fit for the enterprise (Chris Connor, Lotusphere 2012)


Last evening I enjoyed another opportunity to learn Java in Xpages a bit more. This time I took the BP118 presentation because it jumps directly in the area I am working daily in: XPages! After reading the presentation one word was on my mind: Managed Beans.

Managed Beans

  • POJO – configured with getters / setters.
  • Implements “Serializable” (so XSP can read / write from disk).
  • Can be scoped:
    • Request.
    • View.
    • Session.
    • Application.
  • Very useful for:
    • Providing universal access to common lookups.
    • Providing “states” in an application.
      • e.g shopping cart / “one to many” tables.
    • Calling your Java libaries easily
      • BeanName.doMethod() or BeanName.someproperty
        • e.g. uk.bssuk.net.domino.data.ObjectName.doMethod()


Do Not Try to scope Domino Objects. They are C++ Objects and are subject to unpredictable garbage collection (eg NotesDocument, NotesDatabase).

Instead work with primitive types and objects such as String, ArrayLists, HashMaps etcetera. E.g. where a document is required use the UNID instead (String).

Use cases

The presentation describes a couple of use cases where managed beans are used.

Use Case 1 – Lookups

Most databases have lookup lists (e.g. keywords). You should decide on which ones are common:

  • Keep the common lookups in a library for sharing across all databases.
  • Application specific lookups can reside in a class/classes.

Goal from Expression Language / SSJS:

  • Simple call syntax e.g. “Lookup.Locations”.
  • Cached for the appropriate Life Cycle (good for performance):
    • Session.
    • Application.
    • Request.
    • View.

Steps to define a managed bean:

  • Find and Edit the Faces-Config.xml file.
  • Go to the Java Perspective in DDE.
  • Package Explorer.
  • Register your bean by adding XML Contents as shown in the image:


Personal comment: Too bad that the code for the class is not included. I am not sure if a sample database is available somewhere???

A simple call to the bean will get you a cached version of whichever property we want:

  • ArrayLists.
  • Strings.
  • Objects.
    • Not Domino Objects!

Example of a call:

  • More efficient than lots of @DbLookups everywhere.
  • Can deploy in an OSGI library for sharing over all your databases.

Use Case 2 – Line Items

Many applications have 1-to-many tables:

  • Order line items.
  • Expenses line items.

Managed Beans can help with this:

  • Provide a flexible structure for modelling.
  • Abstract out data.
  • No need to worry at early development:
    • Could be response documents.
    • Related documents by key.
    • Relational database table(s) data.

Use a classic MVC

Create a controller class for managing the POJO objects.

  • Adding.
  • Removing.
  • Updating.


  • POJO objects are real life objects (the line items).
  • Controlled by the controlling class.
  • The objects are then “written to disk” as appropriate by classes performing data operations.

Steps to define a managed bean (similar as in Use Case 1):

  • Find and Edit the Faces-Config.xml file.
  • Go to the Java Perspective.
  • Package Explorer.
  • Register your bean by adding XML Contents as shown.


Example: Code for the PersonController class:


What we are doing:

  • ArrayLists for containing Person Objects.
    • An arraylist is bound to a repeat control.
    • Methods for adding / removing Person Objects.
  • When the save button is pressed these objects are “written to disk”.

Use Case 3 – Export to Excel

Personal comment: I guess there are 3rd party libraries available that do better in creating Excel files…

Use Case 4 – Generic workflow process

Nice real world scenario however the code is cut into many pieces and therefore it is hard to follow / see the whole picture. Sample code would do magic here.


This presentation covers more the aspects I am working  daily with XPages. Too bad this presentation has only 51 slides and is therefore very compact. It would be great if a “Jumpstart” session will be made from this presentation at Connect13.

Getting hold on the example code would also be beneficial for learning Java and testing Managed Beans in real world XPages application.

2 thoughts on “BP118 Using Java to build applications fit for the enterprise (Chris Connor, Lotusphere 2012)

  1. Fernando 2013-May-2 / 4:09 pm

    did you found the sample database of this presentation?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s