Wednesday, March 3, 2010

"onload" Event in XPages

Developers who are experienced in traditional web applications in Lotus Notes it becomes a nightmare when they start to work with XPages.

One of the initial issues that I faced is - the struggle to gain control of the onload event in the XPages as the available events in the XPages like the afterPageLoad etc... only allows Serverside script and it becomes expensive to hit the server every time in terms of application's performance.

The following code fragment shall help people who face this issue, and will help them gain access to the XPage's onload event.

<script language="Javascript">
XSP.addOnLoad(alert('I am in XPage onload'));
</script></b>

Add this snippet of code in the Source panel and ensure that it is not nested inside any other existing tags.An ideal place would beneath the lines which say (sort of),

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
 

Now after performing the above step, preview your XPage and voila, you will get the alert saying "I am in XPage onload"

2 comments:

  1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head.
    I am highly impressed with your blog. It is very nicely explained.
    Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

    ReplyDelete
  2. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. event sponsorship

    ReplyDelete