Quick Search
Lotus Community


Sunday
28Jun

Human Readable Dates in XPages

Last year Jake published a really good article (as he generally does) about how to create Ruby style dates in LotusScript. So for example, instead of displaying "28/06/2009 09:35" the page will show "about 30 minutes ago".

It's a technique I bookmarked until I had a need for it, which I now have, but for an XPages app. So I have ported Jakes code across to use Server Side Javascript instead of LotusScript, and in "share and share alike" fashion, thought I should republish it for you to use as you see fit.

So you can download the code here: xpDates.jss 

Please let me know if you spot any bugs.

An interesting side note is, that if you compare Jakes LotusScript and my server side Javascript, you can see just how easy it is to port code from one syntax to the other. So if you're just starting out in XPages development and are worried about losing all of your existing LotusScript agents, there really is no need to. You can spend (an admittedly boring) few hours reformatting and not lose any of your existing code at all.

It may not suit all cases, but for the majority of code it's easier than starting from scratch.

Saturday
27Jun

How to add non breaking spaces to your XPages

Often when you're designing a web page, you'll need a space between elements (such as two field labels for example). Most of the time you should solve your UI issues with CSS, but sometimes that is not the correct answer. Enter   this is a the classic non breaking space that you can use in HTML.

Unfortunately you cannot use that in your XPages source because it is not valid XML, so instead, we just have to use:

 

160 is the decimal character code for the non breaking space and use of character code markup like this is valid in XML.

A very simple tip, but a useful one none the less.

Thursday
25Jun

Thing learned for the day

I'm sure this is well known already, but it was a new one on me.

I have a web form that has a tabular layout of fields. But at the end of each row is a field that mustn't ever get focus (for reasons that are to boring to go into), so I have an onFocus Javascript event in those fields that immediately blurs the focus if the user tries to get into it. All fine and dandy until you try and tab your way around the table, when you reach the end of each row, we end up with no field having focus.

The thing I learned (was told by an exasperated web designer) is that you can set the "tabindex" of a field to -1. If you do this then it is effectively excluded from the tab order of the form as you use the keyboard to navigate around.

Cue much punching of the sky as we knock another bug off the list for the application I'm working on at the moment. It's the little victories that count!

Wednesday
24Jun

The daily constitutional

IMG_0010

I've been working from home pretty much exclusively for over a year now and I really like the more relaxed way of doing things. I can decide my own hours, work when it suits me.

On the flip side, it would be very easy to never leave the flat. So I have tried to get into the routine of heading out for a couple of hours from about 11am every day to stretch the legs and clear the head. This is when living in central London, in the summer really pays off. It really can be a great city.

For example, today part of my walk was from Westminster Underground to Bond Street, through St James' Park and across the Mall (pictured). On a day like today when the weather is sunny and warm, but not too warm. Not too many tourists, life doesn't really get much better.

So if you've never been to London, I highly recommend visiting and walking, it really is a surprisingly compact place once you get your bearings. The tube, taxis and buses are fine if you're in a hurry, but if you're inside Zone 1, then it's normally as quick to walk and much more interesting.

Friday
19Jun

Cross browser testing using VMWare

As an Apple user, when I'm doing Domino development I live in VMWare Fusion to emulate Windows. And since the release of the Windows 7 Release Candidate (free until next year) doing testing in IE6 and IE7 is nigh on impossible. There are tools that you can use to emulate the different browsers (such as IETester) but I have found them to be unreliable.

It's a little know fact that Microsoft actually give out free copies of Virtual PCs setup for IE6 and IE7 compliance testing from their website. Of course because it's a virtual PC image and not a VMWare image we have to go a little further and convert the one to the other. That's where these instructions come in. You'll need to download a conversion tool, the one that worked for me was Q which is actually mentioned in the comments rather than the main body.

Once you've done the conversion, you end up with small (i.e. <1gb) Virtual Machines that you can do "proper" IE testing in until you get the nerve to tell you're idiot IE users that they need to move into the 21st century and start using one of the proper browsers.

Anyway, what it does mean is that you can leave XP and IE6 behind altogether except for your testing which can only be a good thing. Windows 7 really is a big step forwards, even for those of us who don't even like Windows.