Tuesday, September 28, 2010

OnUnload event in XPages

Add the following script block to your xpage. Preview the same and  close it. Once you close your XPage you will get a prompt which depicts the triggering of the onUnload event in xpages.

<xp:this.value escape="false">
window.onunload=function() {
alert('I run on window unload');

A little bit of client techniques to include server side scripts will also work here.

Hope this helps:)

Monday, September 20, 2010

Getting User's Name on the XPage

The content that I am trying to describe on this particular post is fairly simple. Many of you guys out there would have faced it and solved it. But still I would like to share this cos, really XPages are stupid at times.

I had the formula session.getCommonUserName() on a lable which worked for me through out the period I was developing my last application. When I moved the same to a test server to test the same, to my astonishment I found that the label with the above mentioned code displaying my test server's name.

I opened up the XPage in designer, saved it manually,
Signed the database using server id,
compacted the database ,
Restarted my test server etc etc...

All of the above steps failed and it still kept displaying my server name

Later I changed the code to @Name("[CN]",@UserName()), the formula eqivalent in server script.
OOPS that failed tooo...

And after a few brief moments of frustrations, I got the following idea,

And that eventually saved me.

Feels strange aaha...

Hope this helps :)

Roles in XPages

I had a hard time working with user roles in XPages.

  I used to the following procedure which is a server script equivalent of the lotus script equivalent of the @UserRoles which wont work on server side javascript :) (confusing aaha...)

var acl:NotesACL= database.getACL();
var entry:NotesACLEntry = acl.getEntry(@Name("[CN]",@UserName()))
if (entry==null)    {
    entry = acl.getEntry(session.getUserName())
if (entry==null)    {
    return "";


It did work to some extent. But I really had a very tough time with this. It seemed to work fine for a while but to my astonishment it started showing only my server's role enabled on the database . It was very irritating and I felt ridiculous about it.

Later I explored the web to arrive at the fairly simple decent solution as follows,


Yes the above mentioned line did the job for me. Hope this helps some one :)

Tuesday, September 14, 2010

Recover a corrupted archive of the Excel format

One of the readers suggested the following tool for recovering corrupted excel files.

It feels like a handy tool to help in case of excel file corruptions. Also it covers a wide variety of files like *.xls, *,xlt, *.xlsx, xlsm, *.xltm, *.xltx, *.xlam.

I haven't had a chance yet to use it 'cos i dont have a corrupted excel file for the time being (but yes of course have gone through its features :)

Wish I could have had it few months back :).

For more details about the recovery tool click here
 Not feeling patient.... K download it directly

Hope this Helps :)