Personal tools


Feb 06, 2014

XPages and Managed Bean: a new way to process Notes documents

Beans, beans, beans....

XPages and Managed Bean: a new way to process Notes documents

Filed Under:

In this article I want to show an useful method to manage Notes documents using Managed Java Bean and Xpages, instead of the traditional way used so far

Starting from Lotus Domino 8.5, with coming of XPages but especially with the latest releases (9.0 and 9.1), application development is completely changed, especially if you are an "old-style" Domino developer.

XPages and Extension Library fully integrated, together with API as replacement for lotus.domino package, now provides a brand new approach to manage documents, and this is great in terms of performance and reusability.

read more

Dec 04, 2013

Integration between Webservices and XPages: a true story!

Xpages & Webservices

Integration between Webservices and XPages: a true story!

In this article I'm going to tell you about an experience I had having to make a webservice consumer based on SOAP 1.2, and some issues (still unresolved) I encountered

The goal

I have to create a webservice consumer in Lotus Domino using the WSDL provided.

read more

Oct 22, 2013

A brand new Javascript library for progress activity monitoring

XPages with pace.js

A brand new Javascript library for progress activity monitoring

Filed Under:

A brief explanation on how to integrate this new JavaScript library, pace.js, within our XPages. Very cool... and, I hope, very useful

As we all know, the advent of Web 2.0 has introduced many advantages, which of course I'll not mention, such as the ability to make asynchronous calls on a page.

Many times I have used this technology, using some of the most popular Javascript frameworks (Prototype, JQuery ...), but sometimes manage progress indicators can be a little bit boring.

This library is right for us.

read more

Mar 08, 2013

Merging odf files using XDocReport and XPages


Merging odf files using XDocReport and XPages

Filed Under:

Often there is the need to create documents from templates, and the need to fill these templates with data available from other sources: let's take a look at this brief solution

In this scenario, we have a odf template to merge with data.

Working in the Lotus Domino environment, one way to achieve this goal could be a server-side component invoked by an XPagdies, to make the casting process: first, I need something in Java that could do the job for me, and after some search I came across XDocReport.

XDocReport means XML Document reporting

XDocReport provides Java API to merge XML document created with MS Office (docx, pptx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it in another format (PDF, XHTML...).

Basicly, to make the template, main steps are:

  1. create a template document with MS Word (docx) or OpenOffice (odt, ods)
  2. compose the body of the document itself with variables to fill in
  3. use Velocity or Freemarker syntax to set variables to replace.

In this case, I opted to use Velocity inside an ODF file.

Now let's start by explaining how to set up the whole project.

Installing server libraries

External libraries (.jar) that serve the purpose have been installed in the installation directory of the Domino server (jvm/lib/ext path).

These are the files:


Dont' forget an important security setting in java.policy file:

grant {
permission java.lang.RuntimePermission "getClassLoader";
permission java.lang.RuntimePermission "setContextClassLoader";

After that, restart HTTP server.

Server-side tools

To manage the whole process I used an HTML page with a button that calls (via Ajax) an XPages, that deals with the fusion of the data (HTML string) in the template. At the end, I create the PDF file using iText libraries.

Related to XPages, it only call the servlet in the afterPageLoad event:


This is how it looks the package, which includes the servlet:


Finally, this is the servlet code:

package com.redturtle;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.odftoolkit.odfdom.converter.pdf.PdfConverter;
import org.odftoolkit.odfdom.converter.pdf.PdfOptions;
import org.odftoolkit.odfdom.doc.OdfTextDocument;

import fr.opensagres.xdocreport.core.document.SyntaxKind;
import fr.opensagres.xdocreport.document.IXDocReport;
import fr.opensagres.xdocreport.document.registry.XDocReportRegistry;
import fr.opensagres.xdocreport.template.IContext;
import fr.opensagres.xdocreport.template.TemplateEngineKind;
import fr.opensagres.xdocreport.template.formatter.FieldsMetadata;

import lotus.domino.NotesException;
import lotus.domino.Session;

public class XDocReport {

	private static String VERSION = "XDocReport Version 1.0.0";
	static PrintWriter outClass = null;
	private static Session session = null;

	public static void mergeAndPDF (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, InterruptedException, NotesException {

                // NO DIIOP
		try {			
			// 1) Load ODT file by filling Velocity template engine
			InputStream in = new FileInputStream("/tmp/template.odt");

			IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in,TemplateEngineKind.Velocity);

			FieldsMetadata metadata = report.createFieldsMetadata();

			// 2) Create context Java model
			IContext context = report.createContext();
			context.put("comments", "<b>hello world</b>");
			// 3) Generate report by merging Java model with the ODT
			OutputStream out = new FileOutputStream(new File("/tmp/ODTProjectWithVelocity_Out.odt"));
			report.process(context, out);

			// 1) Load ODT into ODFDOM OdfTextDocument 
			in= new FileInputStream(new File("/tmp/ODTProjectWithVelocity_Out.odt"));
			OdfTextDocument document = OdfTextDocument.loadDocument(in);

			// 2) Prepare Pdf options
			PdfOptions options = PdfOptions.create();
			// 3) Convert OdfTextDocument to PDF via IText
			out = new FileOutputStream(new  File("/tmp/ODTProjectWithVelocityList_Out.pdf"));
			PdfConverter.getInstance().convert(document, out, options);
                        // Only manage response to Ajax call
			outClass = new PrintWriter(response.getWriter());
		} catch (IOException e) {
		} catch (Exception e) {
			// TODO Auto-generated catch block

	protected static void printAgent(String string) {

Pay attention to these points:

  1. comments - variable name inside ODF template
  2. metadata.addFieldAsTextStyling("comments",SyntaxKind.Html,false); - fill variable with something in HTML syntax
  3. <b>hello world</b> - HTML string to merge

NOTE: DominoAccess and JSFUtil are two very helpful classes written by Karsten Lehmann: see the full code. Thanks to them, DIIOP process for communication is not required.

Pro & Cons.

I think that it's a very powerful approach; the only limitation I've found is the restricted set of styles supported by the merge process (see there for details). Feel free to make some test using this approach, and let me know what you think :-)

read more

Nov 28, 2012

Mixing Lotus Domino and Twitter together - a way for mobile approach

"Mobilize" your Lotus Domino

Mixing Lotus Domino and Twitter together - a way for mobile approach

Filed Under:

What if you want to create different layouts for different devices in Lotus Domino? This is a way to make this possible, for example using Twitter Bootstrap

It's always more important to develop applications that are accessible from any device so we wondered what it takes to adapt an application, perhaps already developed, to ensure this possibility. In this case, Twitter provides its layout via Twitter Bootstrap, so it was decided to integrate it.

read more