Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Blogs

photo

Yellow is the...

55 Entries |  Tim Tripcony
Updated 
No Ratings 0     Comments 22
photo

TexasSwede

66 Entries |  Karl-Henry Martinsso...
Updated 
No Ratings 0     Comments 59
photo

Lotus Nut

69 Entries |  Chris Whisonant
Updated 
Ratings 4     Comments 96
photo

Urs Meli

19 Entries |  Urs Meli
Updated 
No Ratings 0     Comments 14
photo

Uh Clem's Adm...

35 Entries |  Chris Mobley
Updated 
Ratings 5     Comments 42

Dogear Bookmarks

.Domino Framework

Blog Authors:  Peter Presnell  

All entries tagged with java

Extending a Java Class With LotusScript

Peter Presnell  |     |  Tags:  java lotusscript .dominoframework  |  Comments (0)
In a recent blog I documented a new DominoBES class that has been added to the .Domino Framework.  Due to a current limitation with LotusScript , this class had to be written in Java.  After doing some experimentation I found a way of abstracting the Java Implementation of the class by "extending" the Java class with a LotusScript class.  In theory this allows me to not only publish a Java class as a LotusScript class but to extend the Java class with additional methods/properties developed using LotusScript.
Why bother?  For one thing it is typically not a good idea to mix and match programming languages in an application as code maintenance then requires a developer with multiple programming language skills.  For another, at the site where I am making use of this class there are about 30 full-time Notes developers and several hundred part-time Notes "developers", almost none of whom program in Java.  By choice I am developing the .Domino Framework using LotusScript  wherever I can and using Java where it makes sense to do so because the pool of Note LotusScript developers greatly exceeds the pool of Notes Java developers. 
The following is the code that can be found in the latest beta version of the .Domino Framework for extending the DominoBES class. (Note: I believe both the LotusScript and Java classes can have the same name)
Option Public
Option Declare
Uselsx "*javacon"
Use "base.Domino.MailServices.BES.java"
Use "Domino.Applications"

' C L A S S b a s e D O M I N O B E S ___________________________________________________________________________ C L A S S
'/**
' * Communication with BES Server
'*
' * @author Peter Presnell
' */
Class baseDominoBES As DominoBaseClass

Private JavaSession As JAVASESSION
Private JavaClass As JAVACLASS
Private DominoBESJava As JavaObject
Private MDSHost As String
Private MDSPort As Integer
'/**
' * Constructor
' */
Sub New(),DominoBaseClass("")
Dim ApplicationSettings As New DominoApplicationSettings(Nothing)

Set JavaSession = New JAVASESSION()
Set JavaClass = JavaSession.GetClass("DominoBES")
Set DominoBESJava = JavaClass.CreateObject()

MDSHost$ = ApplicationSettings.BESServer$
MDSPort% = ApplicationSettings.BESPort%

End Sub
'/**
' * Push a browser channel to a Blackberry device. Displays one of two icons on application menu that link to a designated URL opened in teh BB browser.
' *
' * @param Email The email name of the blackberry user
' * @param PushURL The URL to be launched when the icon is selected
' * @param UnreadIconURL URL for the icon to be displayed until the BB user selects the icon
' * @param ReadiconURL URL for the icon to be displayed after te BB user selects the icon
' * @param PushID A unique ID to represent this channel on the BB device
' * @param PushTitle Text displayed along with the icons for the channel
' */
Sub BrowserChannelPush(Email As String,PushURL As String, UnreadIconURL As String, ReadIconURL As String, PushID As String, PushTitle As String)
Call DominoBEsJava.browserChannelPush(MDSHost$,MDSPort%,Email$,PushURL$,UnreadIconURL,ReadIconURL,PushID$,PushTitle$)
End Sub

End Class

DominoBES class

Peter Presnell  |     |  Tags:  java bes blackberry .dominoframework  |  Comments (0)
I am now in the process of extending the .Domino Framerwork to support the publishing of Notes applications on a Blackberry client.  A new DominoBES class has been added as a way of allowing Notes applications to communicate with a Blackberry device via the Blackberry Enterprise Server (BES).  Unlike the rest of the framework, this class has been developed in Java due to the need to send an HTTP POST request.  The first method - browserChannelPush (see below) provides a wrapper for executing a Channel Push, effectively adding an icon to the Blackberry device, which when selected invokes the nominated URL.

import java.net.*;
public class DominoBES
{
  public void DominoBES()
  {
  }
  public void browserChannelPush(String mdsHost, int mdsPort,String email,String docURL, String unreadIconURL, String readIconURL, String pushID, String pushTitle)
  {
    try
    {
      URL mdsURL =  new URL("http",mdsHost,mdsPort,"push?DESTINATION=" + email + "&PORT=7874&REQUESTURI=/");
      HttpURLConnection connection = (HttpURLConnection)mdsURL.openConnection();
      connection.setRequestMethod("Post");
      connection.setRequestProperty("X-RIM-Push-Type","Browser-Channel");
      connection.setRequestProperty("X-RIM-Push-Title",pushTitle);
      connection.setRequestProperty("X-RIM-Push-Channel-ID",pushID);
      connection.setRequestProperty("X-Rim-Push-Read-Icon-URL",readIconURL);
      connection.setRequestProperty("X-Rim-Push-Unread-Icon-URL",unreadIconURL);
      connection.setRequestProperty("Content-Location",docURL);
    }
    catch (Exception e)
    {
      System.err.println("Push failure");
      e.printStackTrace(System.err);
    }
  }
}

import java.net.*;
public class DominoBES
{
  public void DominoBES()
  {
  }
  public void browserChannelPush(String mdsHost, int mdsPort,String email,String docURL, String unreadIconURL, String readIconURL, String pushID, String pushTitle)
  {
    try
    {
      URL mdsURL =  new URL("http",mdsHost,mdsPort,"push?DESTINATION=" + email + "&PORT=7874&REQUESTURI=/");
      HttpURLConnection connection = (HttpURLConnection)mdsURL.openConnection();
      connection.setRequestMethod("Post");
      connection.setRequestProperty("X-RIM-Push-Type","Browser-Channel");
      connection.setRequestProperty("X-RIM-Push-Title",pushTitle);
      connection.setRequestProperty("X-RIM-Push-Channel-ID",pushID);
      connection.setRequestProperty("X-Rim-Push-Read-Icon-URL",readIconURL);
      connection.setRequestProperty("X-Rim-Push-Unread-Icon-URL",unreadIconURL);
      connection.setRequestProperty("Content-Location",docURL);
    }
    catch (Exception e)
    {
      System.err.println("Push failure");
      e.printStackTrace(System.err);
    }
  }
}

Reducing Programming Language Differences

Peter Presnell  |     |  Tags:  vb.net lotusscript oop java c  |  Comments (2)
One of the things that struck me when I attended my first C# programming class was the fact that the instructor was often switching between code examples written in either c# or VB.Net.  These two languages had evolved in such a way that in many ways they had become the same.  This means programmers in one language can more easily adapt to develop/maintain code in the other.  This started me thinking about the opportunity to write Notes applications in such a way that non-Notes developers could better make the transition to develop/maintain LotusScript code.  The same concept also holds true for java, which is not all that different to C#.  The following are some of the coding practices that can be applied to LotusScript to give them a look/feel more like these other programming languages.
Note: The goal here is coding consistency between programming languages.  These suggestions do absolutely nothing to improve the functional nature of the LotusScript code and actually increases the length of the resulting code. 

Object Oriented Programming:
Java, C#, and VB.Net are all examples of object oriented programming languges.  With LotusScript the use of OOP (e.g. classes) is optional.  If you get into the habbit of using OOP when developing Notes applications via LotusScript the chances are the code will be WAY more understandable to a java or .Net developer.  Note: Without a proper class editor for LotusScript it can be a little more painful to maintain code in classes but the pain does subside after a while and a new eclipse editor for LotusScript is not far away...

Error Handling:
LotusScript does not support the try/catch construct found in many modern programming languages, but it is possible to simulate this by adding a non-functional try label at the start of the code and always using catch as the error handling label.  This results in code block similar to the following:-
Try:
On Error Goto Catch
.... (normal code)
Exit Sub
Catch:
.... (error handling)
Exit Sub

This concept can be extended to include the optional finally block used for code to be executed after both normal completion or an error.
Try:
On Error Goto Catch
.... (normal code)
Goto Finally
Catch:
.... (error handling)
Resume Finally
Finally:
.... (final code)
Exit Sub

If... Then... Else
Both java and c# require conditional expressions be enclosed in parenthesese - with LotusScript this is optional.  For consistency make it habbit to use this optional capability of LotusScript.
If (iDocument Is Nothing) Then ... Else ... End If
Method Calls
When invoking a methods (sub or function) with zero parameters in c# or java it is a requirement to place empty parentheses at the end of the method name - with LotusScript this is optional.  Again, for consistency, make it a habbit to use this optional capability of LotusScript.  The use of parentheses helps to make methods distinct from properties.  Note: LotusScript also requires the somewhat redundant Call statement to be used with methods - but thats another story...
Call UIW.ReloadWindow()

Inheritence
Both java and C# support the this statement as a way of referring to methods/properties of the current class.  With VB.Net and LotusScript the equivalent statement is the me statement.  To refer to a property/method in a base/super class that has been overriden in the current class .. notation is used. While it is only ever necessary to use either statement when the same variable/method/property exists in different scopes, it is often a good idea to use either statement to make it clear wherever a method/property defined elsewhere in the class is being invoked.  This also provides a way to minimize the use of variable names like EmployeeName1 to avoid clashes with property names.
If (Me.EmployeeName$ <> EmployeeName$) Then Me.EmployeeName$ = EmployeeName$

If (baseclass..EmployeeName$ <> EmployeeName$) Then baseclass..EmployeeName$ = EmployeeName$



Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About

Tags

A tag is a keyword that is used to categorize an entry. To view the entries with a particular tag, click a tag name or enter a tag in the box.
The tag cloud indicates the frequency of tag use. Popular tags appear darkest. The slider control adjusts how many tags are displayed in the tag cloud.