Saturday, December 31, 2011

Import image resources via LotusScript & Java

People have created various versions where you can import image resources in a NSF database using LotusScript. Basically you mimic the functionality of "Import Image Resource" button present in Domino Designer via code.


Some of the examples can be found here and here. Here is my version of doing this same thing using combination of LotusSciript & Java with LS2J.

Three people icon...

Here are some three people icons similar to Lotus Notes. I will be updating it as when I come across new logos... :)

Lotus Notes

MySpace

Friday, December 23, 2011

"loaded" vs "rendered" in XPages

I couldn’t find many resources on the exact difference between loaded and rendered property available in XPage controls except for this blog by Thiyagarajan.

When you hover your mouse over loaded property it says – “Specifies whether or not the control should be created when the page is loaded.” while for rendered it says – “Indicates whether or not control should be displayed or processed on any subsequent form submission.”. Enabling the properties (exclusively) does not generate the control in the web page. But this is where the similarity ends. It was after a discussion with Sven Hasselbach on XPages forum, I understood the usage of these properties.

Create two computed fields cfLoaded and cfRendered with loaded & rendered property set to false in them respectively. Now add another computed field with following code:

Saturday, December 17, 2011

Accessing XPages global objects in Java

Update 24-Dec-2011: Added method to access session and database.

Update 10-Mar-2012: Updated the view object as it was pointing to a super class. Thanks to Tom pointing that one out.

Update 22-May-2012: Rectified the code to get viewScope. Thanks to Jens Winkelmann for pointing it out.

Update 16-Mar-2013: Added link to get getComponent equivalent in Java.

Tim Tripcony in his reply to one of the questions in the Notes/Domino XPages development forum had suggested using Java over SSJS to improve XPages performance. He basically said – “...Minimize the use of SSJS (server-side JavaScript). Every time any SSJS expression is evaluated, Domino parses the expression in realtime into an abstract syntax tree, then runs Java code that is a rough approximation of how the JavaScript specification states that code matching the detected syntax should run. The more you move your logic directly into true Java classes, the less expensive it is to execute, so it runs faster...

So I started thinking about how can we access various XPages Global Objects like – facesContext, sessionScope, context, etc. from Java classes.


Well... here's how we can access it:

Friday, December 16, 2011

Importing script library in Domino Designer

Domino Designer provides facility to import image resources, style sheets and file resources.


But for script libraries, there is no such option.


So when I need to import a third-party JavaScript script library I usually would create one and then copy-paste the contents into it. But there's an easier way to do it.

Where are the breakpoints stored?

I am sure at some point or another you would have used breakpoints while debugging your LotusScript code. But I always wondered how does Lotus Notes store them. Well, it stores in the profile documents. To view the profile documents in your database there free utilities available like - NotesPeek (my favorite), ProfileMgr by Andre Guirard or NoteMan.

Using NotesPeek you can see a profile document named "breakpoints_" which stores all the breakpoints.


Tuesday, December 13, 2011

Get Java class names for variables defined in SSJS in XPages


Every global object or variable in SSJS is an object of a class defined in Java. The help documentation says that facesContext is an object of class com.ibm.xsp.domino.context.DominoFacesContext. But what about facesContext.getExternalContext() and other variables?

Well in Java every class inherits directly or indirectly from its base class java.lang.Object. This class has a method named getClass() which returns object of class java.lang.Class (Yes, there is a class called "Class" in Java!). With this you can find out to which class the object belongs, its methods, super class and lot more.

Create a new XPage and add a computed field. Add the code given below for its value and preview it in browser.

On a dark foggy night...


This story was was emailed to me by my friend during the appraisal season... Make sure you read it till the end!

On a dark foggy night, a small figure lay huddled on the railway tracks leading to the Chennai station. At once I was held back to see someone in that position during mid night with no one around. With curiosity taking the front seat, I went near the body and tried to investigate it.

There was blood all over the body which was lying face down. It seemed ruthless blow by the last train could have caused the end of this body which seemed to be that of a guy around my age. Amidst the gory of blood flow, I could see a folded envelope which was fluttering in the midnight wind.

Carefully I took the blood stained envelope and was surprised to see the phrase “Appraisal Letter” written on it. With curiosity rising every moment, I wasted no time in opening the envelope to see if I can find some details about the dead guy. The tag around his body’s neck and the jazzy appraisal cover gave me the hint that he might be a software engineer. I opened the envelope to find a shining paper on which the appraisal details were typed in flying colours.

Thunder broke into my ears and lightning broke into my heart when I saw the appraisal amount of the dead guy! My God, it was not even, as much as the cost of the letter on which the appraisal details were printed...  My heart poured out for the guy and huge calls were heard inside my mind saying, “No wonder, this guy died such a miserable death”... As a fellow worker in the same industry, I thought I should mourn for him for the sake of respect and stood there with a heavy heart thinking of the shock he would have experienced when the manager had placed the appraisal letter in his hand. I am sure his heart would have stopped and eyes would have gone blank for a few seconds looking at the near to nothing increment in his salary.

While I mourned for him, for a second my hands froze to see the employee’s name in the appraisal letter... hey, what a strange coincidence, this guy’s name same as mine, including the initials. This was interesting. With some mental strength, I turned the body upside down and found myself fainted for a second. The guy not only had my name, but also looked exactly like me.  Same looks, same built, same name... it was me who was dead there!

While I was lost in that shock, I felt someone patting on my shoulders. My heart stopped completely, I could not breathe and sprung in fear to see who was behind... SPLASH! Went the glass of water on my laptop screen as I came out of my wild dream to see my manager standing behind patting on my shoulder saying, “Wake up man? Come to meeting number two. I have your appraisal letter ready!”

Monday, December 12, 2011

Read only edit box in XPage

In XPages, for edit box there is a property called “Read-only”. This property behaves a little different from the one in normal INPUT tag in HTML. I found this out recently and also posted it on the XPages Forum.


Here is a sample code:


When you preview this XPage in a browser it looks something like this:

Google + Snaptu = Trouble + Confusion


Recently I discovered a beautiful mobile app called Snaptu. It enables users to access variety of services from a single screen like - Facebook, Twitter, News, etc.

There is a very good application for Google Calendar which allows you to add / modify you calendar events. This is actually much better than the Google Calendar for mobile with ability to add events specifying date / time.

But after some days when I accessed my Gmail from browser I got a message that my account was recently accessed from UK....!!!!



A bit worried, I used an IP Address Locator and found that the IP indeed belonged to UK to some website called RackSpace which is basically used for hosting services on web. Now I Googled for "Snaptu RackSpace" and got this link. It basically says that Snaptu is hosted on RackSpace. PHEW! :)

Sunday, December 11, 2011

Creating ticker using JavaScript inside Lotus Notes client

I always felt that the power of JavaScript is Lotus Notes client is underrated. Some articles which do describe this are here and here. I realized this power when a some time back I had create a ticker that worked in Lotus Notes client. You can simply embed an Java applet in the form but, Java applet and Lotus Notes don't gel together very well. You also go for animated table, but then you there would be only specified number of entries (rows) which you be able to cycle through.

Using JavaScript to create a ticker is very similar to creating one for Web browser. To start off create two computed fields on your form - TickerURL & TickerText with their respective field names in their value.


Put an action hotspot around the field TickerText and write the following formula:

Opening design elements with single click in Domino Designer on Eclipse


With Domino Designer on Eclipse one change IBM made was that you needed to double click on the design elements to open them. Very irritating for a Lotus Notes developer who has been developing applications in Lotus Notes 7 or before for quite some time. But thankfully IBM provided an option in the preferences to get the previous behavior.

Open your Domino Designer on Eclipse and go to "File > Preferences". In the “General” section you see option of “Open Mode” where you can select either “Double click” or “Single click”. Select "Single click". Use the image below for reference.


And good old days are back again… :)

Editable field which does not get saved in document when saved


Ever wondered whether an editable field can be created on a form which does not get saved when the document is saved! Well it can be done. It’s pretty simple. All you need to do is to write @DeleteField in the "Input Translation" formula of the editable field in the form.


You can have an elaborate formula written in Input Translation based on which you can decide whether to save the field in document or not.

Validating number fields in Lotus Notes

Anyone who has created number field on form and done validations on that will have faced this problem.

Suppose you have a number field on a form and user enters a value other than number in it and the form gets refreshed, either by F9 (CTRL+F9 in 8.5.x) or via code to validate other fields, then Lotus Notes comes up with a beautiful error of "Cannot convert text to a number".

You don't want this message to come when you want to execute your own custom code to display error messages and show it to user. To get around this error just

User preferences deleted in Lotus Notes 7

Recently on one my colleagues Lotus Notes whenever we went to "File > Preferences > User Preferences..." a dialog box used to show up saying "Document has been deleted".

After searching on Google I found this technote which indicated that if the user is assigned some policy and it has been deleted then this problem may occur and we had policies assigned to users. But technote is talking about problem on server. But still we decided to give it a try. And it worked!
  1. Open "names.nsf" on your local machine.
  2. Go to the hidden view "($Policies)".
  3. Press "SHIFT+F9" to rebuild current view (you must have Manager access on names.nsf). And you are done!

Creating round cornered border table/image in Lotus Notes

Recently I found a property in Domino Designer that you can (actually!!) put a round border to your table. There is a simple table property that enables you to do that.


Open frameset of another database in Lotus Notes


While working on a Lotus Notes client-based application I came across one peculiar scenario that we could not open a frameset residing in another database. You can code @Command([OpenFrameset]; FramesetName) in formula language or Call NotesUIWorkspace.OpenFrameSet(<FramesetName>) in LotusScript. But both these commands open frameset which reside in the same database from which the command is being executed. After searching (read it as Googling) I found a solution by Tammie Miller on SearchDomino. But this required me to modify the target database also. After some tinkering in Lotus Notes I was finally able to do it without modifying the target database.

The Tortoise and the Hare

A long time back my friend sent me an e-mail based on Aesop's famed fable The Tortoise and the Hare which I found pretty interesting. Its a bit long but worth reading. Here it goes...

The Old Story

Once upon a time a tortoise and a hare had an argument about who was faster. They decided to settle the argument with a race. They agreed on a route and started off the race.

The hare shot ahead and ran briskly for some time. Then seeing that he was far ahead of the tortoise, he thought he`d sit under a tree for some time and relax before continuing the race.

He sat under the tree and soon fell asleep. The tortoise plodding on overtook him and soon finished the race, emerging as the undisputed champ.

The hare woke up and realized that he`d lost the race.

The moral of the story is that "Slow and Steady wins the race".

That`s the story which we grew up with!

Here`s the contemporary version of the story and the saga of the race between the Hare and Tortoise continues.. Read on...

The New Story

The hare was disappointed at losing the race and he did some Defect Prevention (Root Cause Analysis). He realized that he`d lost the race only because he had been overconfident, careless and lax.

If he had not taken things for granted, there`s no way the tortoise could have beaten him. So he challenged the tortoise to another race. The tortoise agreed.

This time, the hare went all out and ran without stopping from start to finish. He won by several miles.

The moral of the story : Fast and consistent will always beat the slow and steady.

If you have two people in your organisation, one slow, methodical and reliable, and the other fast and still reliable at what he does, the fast and reliable chap will consistently climb the organisational ladder faster than the slow, methodical chap.

It`s good to be slow and steady; but it`s better to be fast and reliable.

But the story doesn`t end here.

The tortoise did some thinking this time, and realised that there`s no way he can beat the hare in a race the way it was currently formatted. He thought for a while, and then challenged the hare to another race, but on a slightly different route.

The hare agreed. They started off. In keeping with his self-made commitment to be consistently fast, the hare took off and ran at top speed until he came to a broad river.

The finishing line was a couple of kilometers on the other side of the river.

The hare sat there wondering what to do. In the meantime the tortoise trundled along, got into the river, swam to the opposite bank, continued walking and finished the race.

The moral of the story? First identify your core competency and then change the playing field to suit your core competency.

In an organisation, if you are a good speaker, make sure you create opportunities to give presentations that enable the senior management to notice you.

If your strength is analysis, make sure you do some sort of research, make a report and send it upstairs. Working to your strengths will not only get you noticed but will also create opportunities for growth and advancement.

The story still hasn`t ended

The hare and the tortoise, by this time, had become pretty good friends and they did some thinking together. Both realised that the last race could have been run much better.

So they decided to do the last race again, but to run as a team this time.

They started off, and this time the hare carried the tortoise till the riverbank. There, the tortoise took over and swam across with the hare on his back.

On the opposite bank, the hare again carried the tortoise and they reached the finishing line together. They both felt a greater sense of satisfaction than they`d felt earlier.

The moral of the story? It`s good to be individually brilliant and to have strong core competencies; but unless you`re able to work in a team and harness each other`s core competencies, you`ll always perform below par because there will always be situations at which you`ll do poorly and someone else does well.

Teamwork is mainly about situational leadership, letting the person with the relevant core competency for a situation take leadership.

There are more lessons to be learnt from this story.

Note that neither the hare nor the tortoise gave up after failures. The hare decided to work harder and put in more effort after his failure.

The tortoise changed his strategy because he was already working as hard as he could. In life, when faced with failure, sometimes it is appropriate to work harder and put in more effort.

Sometimes it is appropriate to change strategy and try something different. And sometimes it is appropriate to do both.

The hare and the tortoise also learnt another vital lesson. When we stop competing against a rival and instead start competing against the situation, we perform far better.

So the new stratregy paradigm is:
  • The fast and consistent will always beat slow & steady;
  • Work to your competencies;
  • Pooling resources & working as a team will always beat individual performers;
  • Never give up when faced with failures;
  • And finally, compete against the situation. Not against a rival. Challenge Ideas and Issues. Not People.

Configure 24Online for Ubuntu / Linux

At my home I connect to internet using 24Online. The service of this ISP is pretty good with prompt customer support. I recently installed Ubuntu 11.10 with dual boot on my Windows Vista PC. Ubuntu is a pretty good OS, but without an internet connection there's nothing much you can do with it.

For Windows, 24Online provides a UI client.


But for Linux there's no UI client available - only command line utility is available. If you already have an account with 24Online then you can log in your account from browser and download the file from "Client" menu in the website or you can download the file from here (13.2 KB). You can get your IPv4 settings by going to "Control Panel > Network and Sharing Center > Manage Network Connections". Right click on "Local Area Connection" icon and click on "Properties". From the dialog box select "Internet Protocol Version 4 (TCP/IPv4)" and click on "Properties" button. Note down the IP addresses from the fields marked in the screenshot below.


Saturday, December 10, 2011

The first one...

This is my third attempt at blogging my thoughts and learning. My first attempt ended after 1 month and second one after 3 months. Hopefully this time around I will be able to post at regular intervals.

I won't be blogging on any specific subject per se. It would be a mixed bag but mainly on technology, but you may find a lot of posts on Lotus Notes and its related technologies like XPages (after all I am in Lotus Notes development).

And yes, I know the spelling of my blog title is wrong. It's actually a portmanteau of two words - Naveen (that's my name) & Navigator... :) Also I guess all the exciting blog names had already been taken.