How to Use Java package in side Lombardi (IBM BPM) ??

We all know that we can deploy custom jar files to Lombardi and use those classes with connectors.
But do we know that it is also possible to access those classes directly from the server script in the service where write the code using js. Here is an example of how to use that.
First add your jar files inside the teamworks libary which is available in location <installation                     directory>\applications\teamworks.ear\teamworks.war if your are using Lombardi Teamworks 6.2.
Alternatively if you are using Lombardi 7.x , add the jar as server file in the files available in on the Left side palette in the Authoring environment.

Below example is tested in Lombardi 6.2 and 7.1.  The custom jar that is used is itext.jar with slight modifcations.
In the below example we ave tried to create pdf file and save it at the location "applications\teamworks.ear\teamworks.war\html\custom".

var fileRoot = "applications\\teamworks.ear\\teamworks.war\\html\\custom"; 
var iText = + "\\" + tw.local.currentDateString+'-'+tw.system.user_id + ".pdf", "Simple"); 
var norm =; 
var bold =; 
var subHeader ="ComicSansMS-Bold", 16); 
function ITextCreateTable() {
 return new;
 function ITextAddTableHeader(table, title) {
 var para = new, subHeader); 
var cell = new;
 function ITextAddTableBoldCell(table, text) { 
var phr = new java.lang.String(text), bold);

function ITextAddTableCell(table, text) {
 var phr = new java.lang.String(text), norm);
 table.addCell(phr); }
 // Header
 try {
 var doc = iText.doc;, "Onboarding Request for " + tw.local.user.firstName + "\n");, " ");
 // Empty Para for space.. 
// Content
 if (true) {
 var table = ITextCreateTable(); 
ITextAddTableHeader(table, "Account Request");
 ITextAddTableBoldCell(table, "User Name:"); 
ITextAddTableCell(table, tw.local.user.firstName+" "+tw.local.user.lastName );
 doc.add(table);, " "); // Empty Para for space.. 
 if (true) { 
var table = ITextCreateTable(); 
ITextAddTableHeader(table, "Email Request");
 ITextAddTableBoldCell(table, "Email Address:");
doc.add(table);, " "); // Empty Para for space.. 
 if (true) {
 var table = ITextCreateTable();
 ITextAddTableHeader(table, "Profession Request"); 
ITextAddTableBoldCell(table, "Profession:");
 ITextAddTableCell(table, tw.local.user.profession);
 doc.add(table);, " "); // Empty Para for space.. 
 if (true) { 
var table = ITextCreateTable();
 ITextAddTableHeader(table, "Employment Request");
 ITextAddTableBoldCell(table, "Employed:");
 ITextAddTableCell(table, tw.local.user.employed);
 doc.add(table);, " "); // Empty Para for space..
 if (true) { var table = ITextCreateTable();
 ITextAddTableHeader(table, "Social Security Request");
 ITextAddTableBoldCell(table, "SSN:"); 
ITextAddTableCell(table, tw.local.user.ssn);
 doc.add(table);, " "); // Empty Para for space..
 } // Adding a signature field in AcroForm format... 
var acroForm = iText.writer.getAcroForm(); 
acroForm.addSignature("approve", 50, 20, 400, 50); } 
finally { iText.doc.close(); 

Similar script can be written for using any jar. 
Some one can try it and let me know if it is not working.


No comments:

Post a Comment