358 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
Design changes during SmartCloud Notes migration
Mon, Feb 24th 2014 84
Processing multiple users in the SmartCloud Notes administration UI
Fri, Feb 14th 2014 137
The property role is deprecated and no longer supported.
Fri, Nov 1st 2013 95
OpenSocial and Domino - seeking feedback
Tue, Oct 29th 2013 98
I’m on TV for several seconds...
Mon, Jun 24th 2013 82
Followup on getting long-standing bugs fixed
Wed, Jun 19th 2013 69
XPages best practice: computed selection lists
Fri, May 24th 2013 74
Top 10
Processing multiple users in the SmartCloud Notes administration UI
Fri, Feb 14th 2014 137
Better SSJS validation for XPages
Wed, Jan 5th 2011 116
OpenSocial and Domino - seeking feedback
Tue, Oct 29th 2013 98
The property role is deprecated and no longer supported.
Fri, Nov 1st 2013 95
Design changes during SmartCloud Notes migration
Mon, Feb 24th 2014 84
Searching for blank date fields, and what makes a supported feature
Mon, Oct 31st 2011 83
I’m on TV for several seconds...
Mon, Jun 24th 2013 82
XPages best practice: computed selection lists
Fri, May 24th 2013 74
Expand sections on document open
Fri, Feb 4th 2011 69
Followup on getting long-standing bugs fixed
Wed, Jun 19th 2013 69


LS2J static method calls and a little introspection
Andre Guirard    

I've been needing to use LS2J recently so that I could code DNS lookups and web page requests as part of a testing system I'm working on for LotusLive. The documentation is a little vague on how you work with methods in a Java class from LotusScript, so since I had to experiment to find out how it worked, I figured it would be nice to record the information here.

In most cases, you're writing the Java classes you're calling via LS2J, so you get to decide whether there are static members. But maybe you got the class from elsewhere and you don't want to have to modify it, or maybe you're just using a built-in class that you don't get to change. So it may occasionally be helpful to know how to use the static members. So here goes.

You can invoke a static method of a Java class using the JavaMethod.Invoke method with an object argument of Nothing. First you need to get a handle to the method. So for instance, to invoke the static method HTTPPing, which takes a String argument and returns an int, I would write:

       Dim jses As New JavaSession
     
Dim jclass As Javaclass
     
Set jclass = jses.GetClass("TCPClient")
     
Dim result%, url$
      url =
"http://notes.lotuslive.com"
      result = jclass.Getmethod(
"HTTPPing", "(Ljava/lang/String;)I").Invoke(Nothing, url)

The second argument to Getmethod, the method signature, can be a bit hard to come up with. The example in the help shows a sample value of "(I)Ljava/lang/String;", but a single example isn't much help unless the method you want has exactly that signature (and the example seems to be wrong anyway). Rather than try to puzzle out what the right signature might be for the method, I wrote an agent to scan the methods of a JavaClass object and display all the signatures.

       Dim jses As New JavaSession

        Dim jclass As Javaclass
       
Set jclass = jses.GetClass("TCPClient")
       
Dim jmc As Javamethodcollection
       
Dim jm As Javamethod
       
Set jmc = jclass.Getclassmethods
       
Set jm = jmc.Getfirst
       
Dim methods$
       
Do Until jm Is Nothing
               methods = methods &
{
}
& jm.Methodname & " - '" & jm.Signature & "'"
               
Set jm = jmc.Getnext
       
Loop
       
MessageBox Mid$(methods, 2)


which gives the following output:

equals - '(Ljava/lang/Object;)Z' 
hashCode - '()I'

toString - '()Ljava/lang/String;'

getClass - '()Ljava/lang/Class;'

notify - '()V'

notifyAll - '()V'

wait - '()V'

wait - '(J)V'

wait - '(JI)V'

ping - '(Ljava/lang/String;II)Z'

DNSLookup - '(Ljava/lang/String;)Ljava/lang/String;'

HTTPPing - '(Ljava/lang/String;)I'

So we can see from the last entry exactly what the signature argument should be.

---------------------
http://www-10.lotus.com/ldd/bpmpblog.nsf/dx/ls2j-static-method-calls
May 26, 2011
47 hits



Recent Blog Posts
84


Design changes during SmartCloud Notes migration
Mon, Feb 24th 2014 11:00a   Andre Guirard
We've been having a problem with one customer who was migrating their on-premises mail users into SmartCloud Notes, because they ade a mail template change in their on-premises environment after giving us "staging" replicas of some users' mail files. The DESIGN task on the users' on-premises servers updated their mail file designs from the template, and this change replicated to users' local replicas (MMRs in this case). When the users replicated their local mail files with the service, th [read] Keywords: ldd lotus notes server
137


Processing multiple users in the SmartCloud Notes administration UI
Fri, Feb 14th 2014 9:00a   Andre Guirard
I thought I should note this change, since there's nothing in the "liveAdmin" UI (as yet) to indicate how it works. That will have to wait until we can translate the explanatory text into all our supported languages. But you can use the new functionality now. If you have a set of SmartCloud Notes users that you want to -- let's say -- assign a new mail file design using the web-based administration UI, you used to have to search for the user, select them from the search results, click the bu [read] Keywords: administration ldd lotus notes
95


The property role is deprecated and no longer supported.
Fri, Nov 1st 2013 7:13a   Andre Guirard
I recently started using the Domino Designer 9.0.1 client, and immediately noticed this slightly alarming warning in my XPages applications. The product help page "What's new in IBM Domino Designer 9.0.1 Social Edition?" lists several XML elements for which a "role" property is deprecated (search for "Obsoleting of the role property") but it was unclear whether it would still work anyway and how any difference in the build version versus the execution version was a factor. Role is used to [read] Keywords: domino ibm ldd lotus xpages application applications server xml
98


OpenSocial and Domino - seeking feedback
Tue, Oct 29th 2013 12:50p   Andre Guirard
If you've been doing development work that involves OpenSocial and Domino, I'm interested in quizzing you a little. Please reply privately using my email, which is my first and last name, with underscore, @us.ibm.com. Thanks. [read] Keywords: domino ibm ldd lotus development email
82


I’m on TV for several seconds...
Mon, Jun 24th 2013 10:00a   Andre Guirard
At about 1:10 in this news clip: http://minnesota.cbslocal.com/2013/06/23/at-the-fix-it-clinic-learn-to-fix-your-electronics-appliances/ Fixin' stuff. As I do. [read] Keywords: ldd lotus
69


Followup on getting long-standing bugs fixed
Wed, Jun 19th 2013 3:53p   Andre Guirard
A little while ago I wrote about our process for prioritizing bugs for fixing. Mathieu Pape has a related idea recently posted on IdeaJam, that you might consider supporting if you're interested in this issue. It seems like a good notion to me. [read] Keywords: ldd lotus ideajam ideajam.net




74


XPages best practice: computed selection lists
Fri, May 24th 2013 12:50p   Andre Guirard
The low-down: XPages lets you write code to calculate the values for selection lists. The value your code returns may either be an array of strings, using the pipe symbol ("|") as a delimiter between display value and stored value, or it may be an array of javax.faces.model.SelectItem objects, which each contain a display and stored value as separate data items. It's your choice. The latter method, however, is more bulletproof since you don't have to worry about pipe symbols in your data. [read] Keywords: domino ldd lotus xpages application best practice development javascript properties
63


Beware <script> in XPages
Wed, May 15th 2013 12:30p   Andre Guirard
I may be stating the obvious, but I wasn't the only one on my team caught out by this, so I thought I'd best mention it. I recently discovered the hard way that there's a problem with using elements in XPages. Always use instead. Why, you ask? Either seems to work fine! The problem comes up if your application is translated. The code that decides what parts of your page are translatable doesn't know anything about the element, so your JavaScript code is marked as a localizable string. It [read] Keywords: ldd lotus xpages application best practice javascript
51


Working the system to get bugs fixed
Mon, May 13th 2013 9:20a   Andre Guirard
An issue recently came to my attention that (based on my informal poll) has been a thorn in the side for Domino administrators for quite a while. I've been trying to figure out how it is that it's never been fixed. I'm referring to the fact that end users, when they create or rename a folder, are allowed to use various characters that have special meanings in design element names -- backslash, vertical bar, underscore, forward slash (which causes problems in mobile) and enclosing the name in [read] Keywords: domino ibm ldd lotus notes notes client notesdomino bug development ideajam mobile
63


Delete empty folders, take 2
Wed, Apr 10th 2013 9:50a   Andre Guirard
I while back I wrote a post containing code to clean up empty folders from user mail files. Yesterday, someone pointed out to me that it doesn't take into account the fact that folders that contain subfolders can be technically empty, in the sense of containing no documents, but we don't want to delete them if they have subfolders which are non-empty -- or if they have subfolders we don't also want to delete. So I came up with a new version of the code that deals with those situations. As bac [read] Keywords: ldd lotus lotusscript application




Created and Maintained by Yancy Lent - About - Blog Submission - Suggestions - Change Log - Blog Widget - Advertising - Mobile Edition