Serving media files to iPad/iPhone on Domino part 2

Finally, after almost 2 months I finally have time to blog a bit again. This blog will be the second part in a 2 part series about how to serve files for iPad / iPhone devices on a domino server.

Back in part 1 I talked about an xpage application I was developing where the customer wanted to serve video streams to mobile devices. After a couple of days development I got a nice little application running where video’s could be uploaded and watched on all major browsers. The site used the video tag from HTML5 to serve the video files to the browser which accepted this tag. As said in Part 1 mobile safari uses the byte range header to retrieve the first few bytes of a stream to see which type of file is being streamed. By default, as far as I know, the domino server does not understand this header so we have to build this ourselves.

The first step in building this functionality is to create a simple custom control. The custom control contains the following lines of code:

As you can see nothing to fancy, an xp:text box which generates the correct html for the video tag. In the afterPageLoad I generate the correct url for for the video to be played. As you already notice I’m using an xPage as the url for the video tag src attribute. Lets see what happens on the this videoTest page?

The VideoRangeUtil.renderResponse method is called with the current facescontext, the id of the document and the filename we want to retrieve. The renderReponse method looks like this. I have added comments on important places. This code was not completely written by me but was inspired by code from balusC.

Just be aware that this code is not perfect and can be optimized here and there.


Serving media files to iPad/iPhone on Domino part 1


“We want a video library application” they said

“No problem, can be done” I said

“Bad iPad” I screamed!

the lines above are a  little summary of what happened the last few days. At the office  I’m building  a web application which is used to serve Video files. Everything worked fine except for iPhone and iPad devices. I needed to get it working. At first I thought it was a simple encoding issue. So I grabbed my MediaInfo installation, checked the codec information on the mp4 file(s) and spotted that the wrong baseline was used. It was 4 and according to the official apple sources the baseline level needs to be 3.0 (source). So I re-encoded the file and uploaded the new version. I fired up the iPad and noted that the file still didn’t work. Ah! Maybe it was browser caching . So I renamed the file, uploaded it and again.. nothing. On all devices/browser it worked (ie 9, firefox, chrome, safari on windows, my android phone..) except for the freaking iPad!

So being out of options the only thing I could do was head over to stackoverflow and ask my question there. And so I did. Here I present to you a possible solution:

The server needs to support byte-range requests for the mobile Safari ( which is installed on iOs devices ) to be able to play video files using HTML 5.  Byte-range requests? What are byte-range requests I here you think. Actually its fairly easy to explain.

A byte range request is actually nothing more then sending only a little part of the complete file to the client (more). To be able to support this feature a server must react on the range request header and send the Accept-Ranges header accordingly. Because I didn’t know of this requirement I was really puzzled to why the file played correctly on my local Apache install and not on my domino server. To make it even more exciting I tested the following situations

Description Result
File resource Correct
File resource in domino/html Correct
File attachment on document Fail!

As you can see for some reason when serving attachments to the browser the correct headers are not send to the browser. I tried to add them by website rules but of course this failed. Since the system needs to support it as well. So I checked back my question on Stackoverflow to see if there where new additions. And Sven added a little code resource to his answer which actually does exactly that what I wanted.

The code example uses a servlet to serve the file using the range headers if it was requested or the full file if not. I’ve adapted the code and changed it a bit so it is usable for the domino server ( see part 2 for the full code example and explanation ). When you call the code in a beforerenderresponse event with the following line

it will serve the correct file with byte-range support! How cool is that!

In the next Part I will explain to you which code I used and will show you what I changed to get it working for Domino/XPages

Source control to the rescue

For those who own a Qnap NAS system and want to use source control. But dont want to use public repositories like Git: This wiki article explains how to install and run svn on your local qnap. Just be aware that the passwords are by default saved as plain text so be sure your qnap is not directly accesible via the web or so.

I took me less then 5 minutes to create a svn server, a repository and to add my projects from my eclipse client ( indigo ) to the svn server. As a test I removed the project from my eclipse after I posted it to SVN. I created a new project from svn and everything worked fine.

Because my own Qnap is syncing with the Qnap of my family 100km away I can assure now my projects are save.

Next step: Add svn to my domino designer 9 install!

Don’t forget the milliseconds. A post about dates and Datetime comparison

During my work I find working with date and time objects one of the most challenging things. I just spent a few hours finding out that when you retrieve date from a view column the millisecond part of the date is actually not set at all.

In my current project I’m using a date control to set the date of a certain object. After processing I save this data into notesdocument. I noticed when I switched dates ( using a GregorianCalendar ) and retrieved data from the view the documents didn’t turn up on the screen. After some investigation I found out that when using the date-time control for some reason the date is saved but the milliseconds part of the date is not saved at all. This can lead to some frustation.

Let’s show you a little example

Lets say we have the following code



At first glance you might think that the lineDate.getTime and the startDate.getTime() would return the same integer if they point to the same date f.i. 31/12/2012 but in fact they wont..

In my particular case. The lineDate.getTime() returned 1356994800000 and startDate.getTime()  returned 1356994800640. As you can see a difference of 640 milliseconds. This is caused by my first call to the GregorianCalendar.getInstance(). It creates a new calendar instance with the date set to the current date /time. So at a specific point in time there are 640 milliseconds at the end.

When you now compare these two methods and use the system.out.println(linedate) directive you will see something like Mon Dec 31 00:00:00 CET 2012 which is the string representation of that date. Which is the same as system.out.println(startDate). But it wont show you the milliseconds! It took me a little while to realize the millisecond part could be different.

If you know this fact you can work around it by adding 1 line to the above example:


I hope this blogpost helps someone in the future when working with dates in xPages/Java.

Working with Notes designer 9.0

IBM released their next version of Notes in public beta status on the 14th. Since then I’m busy playing around with the new client / designer on my home development box. I have to say they did a great job once again. The client starts very fast compared to the 8.5.x releases and the UI is a big change.

But what’s in for me as notes developer? And especially xPages? At first I was a bit disappointed. I opened up the designer and didn’t really saw something new. So I decided to look around on the net to see if fellow notes dev’s already played around with the designer and of course they did! I watched the excellent video on I would say take a look yourself. But If you don’t want to watch a movie keep on reading. The new features in this notes designer are as follows:

  1. New Jar component in the notes designer.
    • Now you can add easily your jar files you need to the nsf by clicking on the import jar button in the following screen. Unfortunately this is only useful for xPages and can’t be used by Java agents. I hope sometime IBM decides to change this.jar
  2. Content assist in xPage source Editor!!
    • This is actually one of the best, or even the best, new feature in this version of designer. Now it is possible, when you are editing xPages using the source editor to issue type ahead. So for instance for SSJS. I haven’t been able to get it working for own Java classes yet. But I do hope there is somebody out there who knows if this is going to be possible or is possible already.
  3. Hyperlink navigation in xPage source editor
    • In default eclipse when developing Java you can ‘jump’ to another class / or its interface, by holding the CTRL key and click on it. This is very cool feature because you now can go to a separate part of your code without having to search for it in the package explorer. Finally this feature is available in the xPage source editor. How cool is that! No searching in your controls/xpage section anymore.( this is a pain when using lots of controls ).

As you can see alot of new features which will make the life of us developers a lot easier. I have to say after 3 days of playing around with the new designer I really don’t want to go back to 8.5.3 when I’m developing xPages. Because on top of all these great new features i’m noticing a big improvement in times I have to wait for my designer to become responsive again when I pressed ‘build project’.

But it’s a beta so there are some bugs! Atleast I found some.

1. I disabled ‘build automatically since this increases my productivity. When I want to see the result of my change(s) I build the project and go to my webbrowser. What I found is that somehow the build project option is disabled in the project menu. To reconstruct the issue:  Open up a database in designer.

Open a xpage/custom control in source mode.

Close the working set pane and click again the source editor.

Sometimes the build project option will be grayed out and you have to select the project again ( in the working set pane ) to be able to build.

2. Content assist does not work for Java and SSJS resources

As stated above the content assist feature is very very cool and makes it easier. But the content assist is not aware of custom classes (java) I created. It is also not aware of functions defined in included resources. I can imagine this would be a performance drain because you have to parse the SSJS libraries but it would be nice if it could be included.

Tagging to the rescue

A few weeks ago I started to think about digitizing my administration. So any invoice, tax mail or any other official document that would otherwise disappear in one of my big filing cabinets would now be scanned and saved onto my computer.

So I installed truecrypt to be sure the files are being saved encrypted and started to scan the documents. After a while I realized.. wait.. how do i search in all this data? My first thought was ‘tagging’.

So today after a little search on google I decided to create my own litle tagging application. I present to you Tagger. Just be warned. I wrote it just in a few hours and therefore I would call it a beta release. Main features for this application are simple:

  • List files in a certain directory where the program is running from
  • Add tags to the files
  • Search files by tags
  • Save the tag data in a filesystem independent manner.

Features not yet implemented

  • Remove tags from file
  • Show a list of most used tags

Go ahead and download Tagger and tell me what you think !

oh by the way.. the UI is terrible.. I know

Java: Integrating onTime group calendar in your own application

One thing I love about my work is that now and then I get the chance to play with the newest things on the market. Recently I took a look at the Ontime suite. Ontime suite is a application which enables a company, amongst other things, to display a overview of their employee’s appointments without having to open every single agenda. Since a few months the guys at Ontime released a new version which is features a API to communicate with the Ontime application directly using http.

The cool thing about this API is that you can use it yourself to connect to the Ontime application functionality. For instance if you want to add the possibility inside your Eclipse client, Joomla application or WordPress blog to schedule a meeting or display meeting information you can use this API to do so. Currently I’m looking into the possibilities and it looks very promising.

Since I mainly develop in Java during such a R&D project, I created an JAVA wrapper around the API database. I planning to use this wrapper inside my custom Java application to display calendar appointments and create appointments for a certain user.

If this works I can use this wrapper in all Java based applications to communicate with the Ontime API without having to install a AJAX Proxy ( since ajax can’t communicate with different domains and a server based solution can. ) etc.

The cool thing is of course that this opens up possibilities for everyone who has the Ontime suite to integrate its functionality within their own applications!

Responsive webdesign and xPages

As a xpage developer I also need to do some styling from time to time. This isnt a big issue ofcourse unless you need to create an app which is also suitable for mobile devices. Now with the mobile controls at hand it isn’t a big problem developing a mobile website but what if you want to create a website which should look good on mobile and desktop devices and you don’t want to build a mobile and a desktop version of your app?

Here is where responsive webdesign comes in. I’m just learning this myself ( since I’m not a great UI guy.. ) and I already like it. In it’s simplest form all it comes down to is just to add some extra lines to your css files..

Lets say you use the oneui template and you want to hide certain parts when you are viewing the page on an Iphone. You only need to add the following line to the css:


As you can see the right sidebar is not displayed when the size of the screen is les or equal to 320px width. In this very simple way you can add your responsive design to the oneui template without having to create a complete new website for mobile. Unless functionality commands it ofcourse 😉

use of stackoverflow

This is gonna be a short post. A few months ago Niklas Heidloff spoke about the use of Stackoverflow in a session I attended. After a while I started to use it more regularly and I have to admit. It is one of the best sources of information when you want to search for any answers regarding development. I started to work on SugarCRM development a couple a weeks ago and without StackoverFlow it would have taken much much longer to find answers!

A little xPage optimization

When you are developing an application there is a time when performance comes to play. This can be either in the beginning of the project due to certain requirements or after some time developing you’ll notice your application does not performance as well as you thought it would. This post will give you a few tips on how you can increase performance without having to rewrite a great deal of your code.

Because I learn new things myself every project I will update the blog once in a while to reflect the newest findings

Retrieve data from the current component within a event handler:

This is a very easy one but will eventually lead to a bit more performance. Whenever you want to retrieve data from the current component within a SSJS event handler you should retrieve it directly using the following line:

The ‘this’ is a pointer to the current eventhandler. And as you can see this event handler does have a parent property. This parent property is a pointer to the current component where this eventhandler is bound to. It will be faster then

It will be faster because the getComponent() method has to ‘search’ for the component you are looking for where the getParent() method is a pointer to the component directly.