Showing posts with label lotus and java. Show all posts
Showing posts with label lotus and java. Show all posts

Tuesday, July 03, 2012

ViewEntry and Show multiple values as separate entries

When your view has column with option 'Show multiple values as separate entries' and you use ViewEntry to read data from that column you will have a problem. Result of your getColumnValues() can be different, f.x. in 1 case it can be 'Vector' and in another case 'String'. It depends if entry was really split on few entries because of multi-value. I've lookup around and found this issue already reported on IBM ~3 years ago (IBM whats up?)

Full description of problem

Here is a solution I made
Vector v = entry.getColumnValues();
Object o = v.get(0);
String title = "";
if (o.getClass().equals(String.class)) {
 title = (String) o;
else if (o.getClass().equals(Vector.class)) {
 Vector tmp = (Vector)o;
 title = (String) tmp.get(0);

Thursday, February 02, 2012

How do you work with Java libraries in LDD?

Hi guys,

We have faced up (actually long time ago) with problem which is related to Java libraries. Back-end of our applications on Domino is written on Java fully. Each Java library has ofc own classes and packages. However LDD allows to work only 1 person with 1 library at same time and it is really painful for us as we have to wait till another developer finish his job. Does anybody know if there is a way (SVN?) which may resolve our problem?
What we really would like to get - possibility to sync java classes with library, so developers would be able to work with same library and just sync changes to it.
We need something like on screen: java library transform into files and each of file represent own class. So we would sync it in both side...

Any help would be appreciated :)

Thursday, June 23, 2011

How to add much more debug information to your Java Project

Go to Run\Configuration manu and switch to tab Arguments and add:,handshake (as I did on screen) and you will get much more debug information that could be useful for you.

Tuesday, November 09, 2010

Very nice SOAP client (java)

Here is link to nice java soap client
I've implement also LS2J approach

here is my example. There are some enhancements need to do, but anywhere this also works fine.

Java library


public class ECWebservice {
String cResponse;
String wsurl;
String msg;
String contentType;

public ECWebservice(String init_url) throws IOException {
wsurl = init_url;
msg = "";
contentType = "text/xml; charset=utf-8";
cResponse = "";

public String GetResponce() {
return cResponse;

public void SetContentType(String init_contenttype) {
contentType = init_contenttype;

public boolean Send(String init_msg) {
boolean result = true;
try {
msg = init_msg;

// Create the connection where we're going to send the file.
URL url = new URL(wsurl);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;

String SOAPAction = msg;

byte[] b = SOAPAction.getBytes();

// Set the appropriate HTTP parameters.
httpConn.setRequestProperty( "Content-Length", String.valueOf(SOAPAction.length()));
httpConn.setRequestProperty("Content-Type", contentType);
httpConn.setRequestProperty("SOAPAction", SOAPAction);

// Everything's set up; send the XML that was read in to b.
OutputStream out = httpConn.getOutputStream();

// Read the response and write it to standard out.
InputStreamReader isr = new InputStreamReader(httpConn.getInputStream(), "utf-8");
BufferedReader in = new BufferedReader(isr);

String inputLine;
while ((inputLine = in.readLine()) != null) {
cResponse += inputLine;
} catch(Exception e) {
cResponse = "Main: Exception occured - check Java Debug Console";
result = false;

return result;

LS2J library

Option Public
Option Declare

Use "webservice.core"
UseLSX "*javacon"
Class ECWebservice
responce As string
connection As string
contentType As string

Sub New(connection_url As string)
connection = connection_url
contentType = "text/xml; charset=utf-8"
End Sub

Public Property Get GetResponce As string
GetResponce = responce
End Property

public Property Set SetConnection
connection = SetConnection
End Property

Public Property Set SetContentType
contentType = SetContentType
End Property

Function SendXMLRequest(xmldata) As Boolean
On Error Goto errorproc

'** everything we'll need to access our Java classes
Dim jSession As New JavaSession
Dim jClass As JavaClass
Dim jObject As JavaObject

'** get the IGWebservice class and instantiate an instance of it
Set jClass = jSession.GetClass("ECWebservice")

'** version of CreateObject and init with path to WSDL)
Set jObject = jClass.CreateObject("(Ljava/lang/String;)V", connection)
'** send message and get result: true/false, if true then we got result
If jObject.send(xmldata) Then
me.responce = jObject.GetResponce()
End If

SendXMLRequest = True

Exit Function
MsgBox "Error #" & Err & " on line " & Erl & " in function " & Lsi_info(2) & " : " & Error, 48, "Runtime error"
Resume endofsub
End Function

End Class

Saturday, January 09, 2010

iText announced new version of their product 5

I use iText library in some of my LN applications, so I check their site sometimes for updates. Today I found that they announced new version - iText 5 (last one was 2.1.7).
I tried to update my code with that library, but I had to do some changes before, because new library has some changes in naming.

Anywhere it is really good that iText did not stop and moving forward, that's cool. Good job

Monday, October 05, 2009

process image in LN (JPEG and PNG)

I was facing with problem when I got task to process image *.jpg and *.png (get their size and resize big image).

So let me put some code here to show my approach (it is only first version and it means that there are still many issues).

I used LS2J approach.

So here is my Java Library (core):

Option Public
Option Declare

Use "ImageLib"


import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class JpgImage {
BufferedImage originalImage = null;
String fileName = "";
int type = 0;

public JpgImage (String m_fileName) throws IOException {

fileName = m_fileName;

originalImage = File(fileName));
type = originalImage.getType() == 0? BufferedImage.TYPE_INT_ARGB : originalImage.getType();

}catch(IOException e){

public int ImgResize (int w, int h)
String newFileName = "";
String imgFormat = "";
newFileName = fileName.replace(".", "-thumb.");

if(type == 5) {
imgFormat = "jpg";
else {
imgFormat = "png";

BufferedImage resizeImage = resizeImage(originalImage, type, w, h);
ImageIO.write(resizeImage, imgFormat, new File(newFileName));

}catch(IOException e){
return 0;

public int getWidth (){
return originalImage.getWidth();

public int getHeight () {
return originalImage.getHeight();

private static BufferedImage resizeImage(BufferedImage originalImage, int type, int w, int h){
BufferedImage resizedImage = new BufferedImage(w, h, type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, w, h, null);

return resizedImage;

LS code.

Option Public
Option Declare

Use "ImageTest "

Uselsx "*javacon"

function add/change image (it creates Thumbnail version of original image with max size 120x120)
add image to Body and BodyThumbnail fields
On Error Goto processError

Dim jpgClass As JavaClass
Dim jpgImage As JavaObject
Dim jpgImageThumbnail As JavaObject
Dim jError As JavaError

Dim w As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim uidocnew As NotesUIDocument
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Dim bodyThumbnail As NotesRichTextItem
Dim filepath As Variant
Dim vFileNameThumbnail As Variant
Dim tmp As String
Dim filename As String
Dim filenameThumbnail As String
Dim picH As Integer, picW As Integer
Dim picHT As Integer, picWT As Integer
Dim debug As Boolean

debug = True
If debug Then Print Lsi_info(2) & " starts at: " & Now

Set uidoc = w.CurrentDocument
Set doc = uidoc.Document

filepath = w.OpenFileDialog(False, "Please select iamge", "JPG|*.jpg|GIF|*.gif|PNG|*.png|", "", "")

If Not Isarray(filepath) Then Exit Sub

filename = filepath(0)

'** everything we'll need to access our Java classes
Dim jSession As New JavaSession

'** get the JpgImage class and instantiate an instance of it
Set jpgClass = jSession.GetClass("JpgImage")
Set jpgImage = jpgClass.CreateObject("(Ljava/lang/String;)V", fileName)

'get width and height of images
picH = jpgImage.getHeight()
picW = jpgImage.getWidth()
Call doc.ReplaceItemValue("picH", picH)
Call doc.ReplaceItemValue("picW", picW)

'attach image to as it is to body field
Call doc.RemoveItem("Body")
Set body = New NotesRichTextItem(doc, "Body")
Call body.EmbedObject (EMBED_ATTACHMENT, "", filename)

' new image
If picH > 120 Then
picHT = 120
picHT = picH
End If

If picW > 120 Then
picWT = 120
picWT = picW
End If

Call jpgImage.imgResize(picWT, picHT) '** shrink to 50% of the original size

If Instr(filename, ".gif") Then
Dim original_name As String
original_name = Replace(filename, ".", "-thumb.")
fileNameThumbnail = Replace(filename, ".gif", "-thumb.png")
Name original_name As fileNameThumbnail
fileNameThumbnail = Replace(filename, ".", "-thumb.")
End If

Call doc.ReplaceItemValue("picHT", picHT)
Call doc.ReplaceItemValue("picWT", picWT)

'attach thumbnail version of image
Call doc.RemoveItem("bodyThumbnail")
Set body = New NotesRichTextItem(doc, "bodyThumbnail")
Call body.EmbedObject (EMBED_ATTACHMENT, "", fileNameThumbnail)
Kill fileNameThumbnail

doc.SaveOptions = "0"
Call uidoc.Close(True)

Set uidocNew = w.EditDocument(True, doc, , , , True)
Delete uidoc
Call uidocNew.Document.RemoveItem("SaveOptions")

Call uidocnew.Refresh

If debug Then Print Lsi_info(2) & " starts at: " & Now

Exit Sub
'** report any errors we get and keep on going
Set jError = jSession.getLastJavaError()
If (jError.errorMsg = "") Then
Print "Notes Error at line " & Erl & ": " & Error$
Print "Error at line " & Erl & ": " & jError.errorMsg
End If

Msgbox Error$

Resume basta

End Sub

btw, then I found more interesting solution (at least I think so :-D) on

Tuesday, January 20, 2009

Transfer file to WebService and Encode/Decode base64 string

I had a task where I should give opportunity to user send file to WebService written on Java. File always should come as decode base64 string, and in WebService I should decode string to normal (it should be DXL content as result) and then import it in a special database, so I had small problem with decode/encod (dont know why but it was happen). So here this simple exmplae how to do it

public class Base64Test {
public static void main(String[] args) throws IOException {
String str = "my string";

String s = new BASE64Encoder().encode(str.getBytes("UTF-8"));
byte[] bytes = new BASE64Decoder().decodeBuffer(s);
String result = new String(bytes, "UTF-8");

Friday, April 18, 2008

View applet - ext. problem.

Nothing news to be honest, but for me it happened first time. I had a task with View's applet, it didn't work correctly in several users and on my PC. It was simple applet, you can see it below my text.

the problem was in cab ext. I found that I have to switch off JRE support in my browser, or just to modify the ext. to jar.

Sunday, February 18, 2007

Difference between “garbage collector” in Lotus Notes/Domino and Java

As you know, when you work with Lotus Notes/Domino as developer, you never think about deleting objects. I mean, when you create a new NotesDocument you never delete it because Lotus Notes/Domino do it automatically. It’s really good feature if you work with Lotus Script, but when you write on Java, for example, Agent on java, you must always use method recycle() for memory release. I want admit, when you call method recycle() for object_A, then method recycle() automatically call for any objects that are created from object_A. It means that calling recycle() on a database object will also do recycle() for all objects obtained through this database.

It is important to remember that only one reason for calling recycle() is to release memory when you write an on java.

Wednesday, February 14, 2007

Notes.jar and Eclipse

Yesterday I tried to connect Notes.jar (java library in Lotus Notes) to my simple Java application in Eclipse 3.2. I had some problems with it. When I added Notes.jar and tried to compile my project, debugger gave me an error. I began to search information about it and found interesting article. A problem was very simple, I didn’t think about “Environmental variables”, so when I added them, my application was compiled!