Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search


Home > Server JavaScript > Work with events
xpageswiki.com
is maintained by 
Julian Buss.
You can hire me.

Work with events

ShowTable of Contents
In short, the events of a XPage with two custom controls (controlA and controlB) are executed in the following order:

events executed once



  • Xpage -> beforePageLoad


  • controlA -> beforePageLoad


  • controlA -> afterPageLoad


  • controlB -> beforePageLoad


  • controlB -> afterPageLoad


  • Xpage -> afterPageLoad


events executed on a full or partial refresh



  • Xpage -> afterRestoreView


  • controlA -> afterRestoreView


  • controlB -> afterRestoreView


events executed sometimes on a full or partial refresh



  • Xpage -> beforeRenderResponse


  • controlA -> beforeRenderResponse


  • controlB -> beforeRenderResponse


  • Xpage -> afterRenderResponse


  • controlA -> afterRenderResponse


  • controlB -> afterRenderResponse


tipps


Place code to execute once when the page is initially loaded to PageLoad.
Place code to execute on every refresh to afterRestoreView.
Note that the afterPageLoad event of the XPage is executed AFTER all component's afterPageLoad events.

Taken from Peter Presnell - thanks!

using event object


In the event handler, you can use the following:

this.getParent().getValue() returns the value of the event's component.
this.getParent() returns the event's component.
this returns the event handler object.

using the event object in client side javascript


In client side javascript, there is an object named "thisEvent" in any event handler (for example in an onlick event).
So you can call a function like this:

myEventFunction(thisEvent)


function myEventFunction(e) {
  alert("raised event: "+event);
}


Event objects may be different among browsers, use this to fix that:

var e = dojo.fixEvent(thisEvent);
// now do something with the new event object stored in 'e'


For example to do something on ENTER, write this in the onkeypress event of the input box:

e = dojo.fixEvent(thisEvent);
if (e.keyCode == dojo.keys.ENTER) doSomething();

Use partial execution mode


There is a checkbox "Set partial execution mode" and the possibility to set a "execId" on a event handler. That is useful to restrict the scope of the event, so that not the full XPage but only selected components are recalculated.

See Paul Withers blog entry for details.
Created by Rene on May 10, 2011 10:47:32 PM

I am trying to get the event object in my onKeyDown event to do phone number validating and it's not working:

event is not a reserved object.. help!


Created by Julian Buss on May 27, 2011 2:09:38 PM

I just found that the event object is not present in all browsers. You can use "thisEvent" instead.


Add Comment

Name:
Comments:
How to take your XPages App to the iPhone, iPad, Android: use Domino To Go!
Do you look for an XPages Workflow solution? Take YouAtNotes Workflow.