JMP102 – Eating the Elephant A Java Jumpstart (Paul Calhoun, Lotusphere 2012)

Introduction

The title reflects also a bit of the presentation. The presentation contains 162 slides so you better prepare yourself for a long journey.

Here a summary of the lessons learned. I divided the presentation into categories.

Section Java language fundamentals

A lot of focus on this. Not so much news here.

Section Java Domino Objects

  • Only implements the “Back End” objects.
    • Exposed via:lotus.domino.*
  • No Notes Client UI access.
  • You (the Domino Developer) already know 98.67 percent of all of the Java class names for the Domino Back End Objects.
  • Drop “Notes” from the front of the LotusScript class names equals Java class names.

LotusScript Class Name

  • NotesSession
  • NotesDatabase
  • NotesView
  • NotesDocument
  • NotesItem

Java Class Name

  • Session
  • Database
  • View
  • Document
  • Item

 

These Java Classes don’t exist in LotusScript:

  • AgentBase
  • AppletBase and JAppletBase
  • NotesError
  • NotesException
  • NotesFactory
  • NotesThread

 

  • Java has no “Variant” data type.

Section Java Agents

  • Java Agents MUST extend AgentBase
  • Java Agents MUST use the NotesMain() method as the entry point for their functional code
  • The getSession() method creates a Session object

 

  • The Default Agent Code only catches generic exceptions
  • Add an additional catch block for NotesExceptions:

import lotus.domino.*;
public class MyFirstAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
}catch(NotesException ne){
ne.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}

DDE Tip Snippets Eclipse view

An overlooked feature in DDE how to store and share re-usable code, e.g. Java code.

Java in XPages

  • Java Code can be called from any Server Side JavaScript (SSJS) event in the XPage

Section Third party Java libraries

Using Third Party Java Libraries in XPages:

  • Unzip the downloaded file to an accessible drive.

Add to the Application or Deploy to the Server?

  • Access to the library API can be accomplished two ways:
    • Adding it directly to the (every) application that will be using it.
      • Not a best practice but sometimes necessary for portability or when deploying .jars to the Domino server is not an option.
    • Adding it to the Domino server.
      • Best practice.
      • It is then available to all applications that will utilize it.
      • It can be “upgraded” to the next version and then is globally available

Regardless of the choice, the code is written the exact same way.

  • This allows for deployment using either option and then changing it later

Adding the Jar to the Domino Server.

  • Library class and jar archives can be added to the xsp folder in the Domino program directory.

Adding the Jar to a Specific Application

  • The POI jar can also be added to a specific application.
  • Switch to the Package Explorer view.
  • Expand the Virtual Project folder.
  • Expand WebContent | WEB-INF.
  • If a “lib” folder already exists, add the jar file to this folder.
  • If the “lib” folder does not exist, then create the folder and add the jar file.

 

Example XAgent Code

The XAgent (an XPage with no UI design elements) code will be used by all three use cases to create the spreadsheet.

  • The code is in the beforeRenderResponse event.

Import the Needed Packages in XPages.

  • This makes the classes in the included jar file available to the SSJS code.
  • The org.apache.poi.hssf.usermodel package contains all the classes needed to create the Excel spreadsheet.

//import the appropriate java packages
importPackage(java.lang);
importPackage(org.apache.poi.hssf.usermodel);

3 Use Cases

There are three primary use cases explained for exporting Domino data to Excel:

  • All documents in a view.
  • Selected documents in a view.
  • Document collections from a query.

Summary

This session gives a good introduction of Java fundamentals, introduces Java for LotusScript developers and touches Java in XPages.

In the XPages section 3 use cases for an XAgent is explained that uses a third party Java library.

I am not sure if the code of the export use cases is available for public?

More Java on my road ahead…

Introduction

Like so many Notes developers I have read a lot about Java as I should like some experts say or claim. However I never have been in the situation that I have dealt a lot with Java in development projects or I have chosen for other technologies (SSJS, LotusScript, Flash) to work around/avoid making Java an integrated technology in my projects.

I have no reason to question any good intentions of these experts so I decided to pick up the glove and study Java development from a DDE 8.5.3/XPages perspective.

In this blog I write my approach, hopefully it will help me (and others) understand if I should make Java part of my development skills in XPages and the promoted way to do this. I especially will look to easiness, quick wins, quality improvements, benefits and new opportunities.

Job market

As other Notes developers I am a bit concerned about my opportunities on the job market. I do not see so many ‘explicit’ demands after Notes or XPages developers. Including Java will broader my perspective is my assumption. If so, this will help making me become a ‘true believer’ =)

Background

Maybe it is good to understand my technical background. I have been working for a long time +10 years in Notes Domino development, written with @Formula/@Function, LotusScript, JavaScript, HTML, CSS, XML and recently XPages numerous applications both for the Notes client as for the Web browser.

I have followed some JAVA education. I have followed once a course how to write Java Servlets and use them in Agents (R5, Appligate I believe). A year ago I attended a course ‘Coding better Java’. Long ago I have read the Domino Development with Java book, remember that one? Off course I have also read the Head First Java book.

I also gave support to a large application that used Java in a couple of agents which I found the code easy to understand.

XPages

So you can say I basically understand the technology but this is most from a theoretical perspective. Since I am working mostly in XPages projects the last 3 years I am have been looking for tutorials or course-ware that could convince me to jump on the Java bandwagon. I found the following course ‘Java 1 for XPages Development (link)’ but I am doubtful how much this will help me using Java instead of it is focussing on Java in general?

Off course it is highly appreciated in case you know a resource that can help me along the way. While I am considering the offering from TLCC I decided to dive into my collection of presentations from events (The View, Lotusphere) I have attended or received from colleagues.

Study material

Below is a list of the material I went through and found relevant to spend time on. I will review each one of them.

I have presentations from previous events, mostly from Lotusphere and The View. I will include them in my study later. In case you have a tip for a resource that is not in the list above, please let me know.

I will also include some webinar or video material, simply because it saves me time and they are easy to consume. Here is a list of items I have looked at:

If you have contributions to complete this video-list, please let me know.

Let’s get started!

Okey I guess it is time to take the red pill now.

Bildr – A photo sharing project

Bildr is a prototype application that never received enough funding to become a full blown (internal) Notes template. The idea is to offer a place where teams can share high resolution images.

Bild is  the Swedish word for photo and Bildr refers ofcourse to Flickr.

Another reason why I stopped prototyping the database is that I started looking at XPages and the limitations I experience with pre-XPages development. To shorten it: it takes just too many design elements to build it in the old-fashioned way to be able to offer a Web 2.5 experience. Maybe after a long break I will move the idea behind the application into an XPages based solution.

For now you can download the application and use it as a start for your development project.

What’s in it?

1. Easy import and thumbnailing of images (Notes client)

Open any of the Picture views and select the New Upload button.

bildr01

The idea is that you can upload multiple images at once in a new or an existing category. You can add tags and a description to the to be created document(s). New uploads you may want to appear in the ImageFlow gallery in the startpage and you can enable commenting and read restrictions.

bildr02

When you select the Upload Images action button you can select the pictures you want to upload. The code behind this function is taken from the NSFTools site (I guess). After uploading you can select to include more images or just leave it as it is.

Behind the scenes each picture is included in a Notes document with also a mid-size image and a thumbnail:

bildr03

For the Notes client that is just it. Nothing more exciting here except some gaps in the completeness of the functionality (hey, I was talking about a prototype).

2. Presentation (Browser)

For the way of presenting different elements I guess I was so bold to use Jake Howlet’s DomBlog Template (for search, calendar, commenting, RSS etc.) which was for a long time a learning application for many Domino developer. I guess if you compare the layout with that of LinkedIn you will see some comparison.

bildr05

3. Tagcloud (Browser)

For the Tagcloud I got some help.

bildr04

4. ImageFlow Gallery

bildr06

5. Lightbox

I guess Lightbox alike functions are almost unthinkable when looking at high resolution images so this I also included when clicking on a mid-size or thumbnail image:

bildr07

What is it not?

You can not call this app a production ready application. Some things are not in place (like cleaning up categories and corresponding image documents). However it can be a nice starting point for a mature application. Untill now I experienced little or none errors so please give it a try and send me the end result of you modification.

Steal with pride and improve! (11 MB)

XML4j.jar and LotusXSL.jar installed on server – How to investigate which applications are using them?

We have some additional programs installed on our servers which are a legacy of previous versions of Domino. With the preparation for an upgrade to 8.5 we are investigating if we still need them.

For example in the Notes 8 Designer Help I read:

Lotus Domino Designer includes the XML4J parser and LotusXSL processor in the product so you can parse and transform XML data without a separate download.

  • What is the easiest way to investigate if any application is still using these programs?

(ps our environmentscomes near to 10.000 applications)

The Lotus Symphony Developer’s Workshop

 

Symphony API
Symphony API

Today I received a question from a developer who received the question from a customer to store Notes documents as PDF’s via a scheduled agent.

I remember the workshop “The Lotus Symphony Developer’s Workshop” @Lotusphere where in one of the excercises you transformed Symphony documents as PDF’s.

John D. Head wrote in the BP110 presentation:

“We can use a Java Agent to automate Symphony”,

which tends me to say: Yes, it should be possible to convert Lotus Notes documents to PDF using Lotus Symphony on a scheduled basis. Or am I wrong?

Ps. Has anyone the material/excercises/instructions from this hands-on lab?