Tuesday, November 13, 2007

SnTT : Using DXL and Java to update view designs

In a recent project I needed to apply a new corporate interface design to a bunch of databases. Modifications to frames, pages, forms and views. The objective was to provide consistency for the end users. Updating the views was by far, the most time consuming and tedious part. I needed to find a quicker and easier way before I ended up with RSI.

Enter DXL, with a dash of Java. I decided that Java and Eclipse would a better choice
rather than Domino Designer and LotusScript. As a tool it would be independent of a notes database and there are plenty of dom and sax parsing libraries to choose from. I also chose to use eclipse so that I could ensure that the tool could be used and extended further by my client.

The objective of the tool was to export the DXL for all the views in a database, then add or modify particular elements to change the style, colours and which shared buttons appear for each view. The modified DXL would then be imported into the database to make the changes.

Below are snippets of the important pieces of the puzzle.

Here I export the views DXL into the DOM parser

DxlExporter exporter = s.createDxlExporter();
org.w3c.dom.Document doc = fac.newDocumentBuilder().parse( new InputSource(new StringReader(exporter.exportDxl(note))));

Then manipulating the actionBar node background colour, borders and style

actionBar.setAttribute("bgcolor", "#004573");
actionBar.setAttribute("bordercolor", "black");

actionBarStyle.setAttribute("height", "40px");
actionBarStyle.setAttribute("repeat", "resize");
Element imageRef;
imageRef = (Element) actionBarStyle.getElementsByTagName("imageref").item(0);
if (imageRef == null)
imageRef = doc.createElement("imageref"); actionBarStyle.appendChild(imageRef);
imageRef.setAttribute("name", "fade-blue-blue.gif");

And then import the modified XML DOM into the database

ByteArrayOutputStream bs = new ByteArrayOutputStream();
OutputFormat fmt = new OutputFormat(doc);
XMLSerializer writer = new XMLSerializer(bs, fmt);

Stream stream = s.createStream();
stream.setContents(new ByteArrayInputStream(bs.toByteArray()));
importer = s.createDxlImporter();
importer.importDxl(stream, dbTarget);


There were a few gotchas where the importer expects elements in certain order and a particular nasty bug in 7.0.2 that corrupts the view/column formulas. As far as reducing the monotony in updating a design I would highly recommend this approach and hopefully you can take the skeleton code and extend for you own purpose.

You can download the workspace zip file. You'll need to update the location to the NCSO.jar and Notes.jar libraries from my location of c:\lotus\notes.

WARNING : You must ensure that you are using Lotus Notes Designer 7.0.3 otherwise you will corrupt your views - see this technote and try it on a test database.
I haven't tried this in version 8.0 either.


  1. Anonymous5:13 am


    I am trying similar to what you have done. But not able to manage to export Form DXL using java application.

    I used below code. It is always returning databaseinfo, but not the forms or views. NotesCollection has forms. Because when I print the count it is displaying. Can you please help me in suggest me what went wrong.

    NoteCollection nc = database.createNoteCollection(false);

    System.out.println("Count "+nc.getCount());
    String xml = exporter.exportDxl(nc);


  2. Hi Srinivas,

    Sorry, it's been a long time since I coded Lotus Notes & Domino. I would suggest posting the question into the support forums. I would also suggest that you include more diagnostic information and also perhaps even which version you are using. I doubt that anyone will help unless you provide those details.

    Good Luck!