Kotlin Index of Maximum problem

January 28, 2012 § 3 Comments

On the Kotlin demo site there is some problems to solve. Here is my solution to the ‘Index of Maximum’ problem.

fun indexOfMax(a : IntArray) : Int? {

  if (a.size == 0)
    return null

  var max : Int = Integer.MIN_VALUE
  var maxPosition : Int = 0

  for (i in a.indices) {

    if (a[i] >= max) {    
      max = a[i]
      maxPosition = i     


  return maxPosition


I think Kotlin is an intresting attempt at a new language. Now I really would like to try it out in a real IDE.


Inheritance of .class-files in the package explorer in a Domino application

September 5, 2011 § 2 Comments

We have had great problems with XPages in one of our applications.

We have an application that is based on a template. The XPages in the application calls java code that has been added to the package explorer in .java-files and jars.

We had determined that the problem somehow had to do with the signing of the design elements (we mostly got error like ‘sessionAsSigner not found’), but we could not really understand what happened. But now we have learned that the complied .class files in an application is by default set to disallow inheritance. This means that the production database did not inherent the updated .class-files from the template. This then led to the signing problem. So I think that the thing to do is first update and sign the template. Then clean (without build) the production appplication. Thirdly you should inherent the template and then build the producgtion application. And finally sign the production db with the same ID as the template (haven’t tested yet but it seems right).

Dojo Data Grid problems in XPages

February 4, 2011 § 3 Comments

I’m working on a project where I need to use an Dojo Data Grid (djxDataGrid) to enable Excel like editing. (As a note I can mention that I’m using the XPages Extension Library from OpenNTF to accomplish this.)

I want to present a selection of documents from a Domino View. The problem is that I get empty rows for those documents that should not be presented:

I use a RestService control to collect the data from the Domino View. This service is of the type viewItemFileService (I have also tested another of the types with the same result, the distinction between the different services is not clear to me).

I have tried using either the property categoryFilter or the key propert. Both with the same unsatisfactory result.

I have also tried to set a readers field to limit what is shown in the data grid. The result is still the same.

Another way to solve my problem is if I could bind a javascript object directly to the data grid (this is actually the preferred way as I originally don’t have the data as Notes Documents). I haven’t been able to find any documentation about how this could be accomplished.

I guess I will have to read the source for the custom controls in the extension library and try to figure out if it is doable.

CKEditor in Lotus Domino

November 21, 2010 § 2 Comments

After spending a few hours dismantling the CKEditor in Domino this is what I have found out.

It is a quite a lot of JavaScript code that makes the Domino implementation of CKEditor tick. Most of the code is unaltered for the Domino implementation, but there are some changes. You will find the the code for CKEditor in the folder <data folder>\domino\html\ckeditor\ on the domino server.

By using a tool like grep you can search for any file withe the word IBM in it and you will find the files that has been altered for the Domino implementation. Also please note that the JavaScript files each as two versions one obfuscated for size reasons and one with the original code. You will find the readable versions in the folder _source.

If you want to change how the editor works I would not recommend you to make changes in these files. It is better to programmatically change the things you want to change. The problem with xPages is that it can be hard to guess the id that is assigned to different elements. And that makes it harder to get a handle on an element. One way to do this for the CKEditor is to loop through all instances and get the name of each instance. This example isn’t very useful, but you get the idea:

for(var i in CKEDITOR.instances) {
    alert(CKEDITOR.instances[i].name); // alerting for testing purposes only

Also note that the name of the CKEditor instance is the same as the id-tag of the containing textarea-element.

To get the CKEditor integrated into the whole xPages thing there are also a couple of dojo-files needed. You will find these files in the folder <data folder>\domino\js\dojo-x.y.z\ibm\xsp\widget\layout\ (where x.y.z is the current dojo-version used by Domino). The interesting files for the CKEditor-integration are xspCKEditor.js and CKEditorWrapper.js.

The file xspCKEditor.js defines the ajax-call used for uploading an image to the server. The return value of this call contains a short code snippet that contains the URL to the uploaded image.

var url = document.location.href.substring(0, document.location.href.indexOf('?'));
if(null != url){
  this.filebrowserImageUploadUrl = url +
    "?$$axtarget=" + options.id +
    "&$$viewid=" + XSP.findForm(options.id)["$$viewid"].value +
    "&command=QuickUpload&type=Images&SessionID=" +

I have not been able to find any documentation of what argument the call can use, but you can make some deductions from the code itself. And you should be able to make your own upload controls by following the patterns in the code above.

As the other half of the programming crew in my shop is quiting around Christmas I won’t be able to take the time to experiment with his. But maybe you, the unknown reader, have the time 😉


XPages course

November 8, 2010 § Leave a comment

I’m currently taking the online video course about XPages on the site xpages101.net. It’s great. Matt White is both very skilled in XPages and a really good teacher. So if you want to kick start your Xpages programming (and have the funds) I can really recommend this course.

jMonkeyEngine 3

October 16, 2010 § Leave a comment

jMonkey is a Java 3D game engine. It uses OpenGL via LWJGL and JOGL. For sound it supports OpenAL.

The release of version 3 of the engine is drawing near. A really nice feature is that they have implemented an IDE called jMonkeyPlatform. This IDE is based on NetBeans and has everything ready for game development.

I installed the Aplpha 2 on my Ubuntu 10.04 first, but I had problems with the SceneViewer Window. I haven’t solved that problem. On my Vista box, it plays niceley, though. If you try to install it on Ubuntu do not install it as sudo. Use your normal user to install it.

I haved worked my way through the Tutorials for beginners. With the jMonkeyPlatform the tutorials are easy to follow as most libraries is preconfigured. The only not totally obvious thing was that the models used for some of the tutorials was stored in the jme3testdata jar. You have to include that in your project to be able to run the examples. To do that, right-click on the Libraries-folder in your project explorer and select ‘Add Library…‘. You can then select the needed library from the list:


Select jme3-test-data to include it in your project


The tutotials has simple examples for most everything you want to do like picking, animation, asset handling. It is really easy to start 3D programming this way.

If you have trouble finding the javadocs they are in the zip-file jMonkeyEngine3-javadoc.zip.

Image problems with CKEditor in version 8.5.2 of Lotus Domino

October 5, 2010 § 1 Comment

There seems to be an problem with the persistance of images uploaded directly with the CKEditor.

IBM are working on a fix for this (there are a SPR on this and it will be adresses in 8.5.3, according to the support). But there are a workaround that can be used. On the Xpages-tab in the database properties select ‘Keep only the current page in memory’:


Click to enlarge


(This is instead of the default value of ‘Keep pages on disk’).

The property must be set for every database you want to use this functionality in.

Where Am I?

You are currently browsing the programming category at Strange Epiphany.