views:

90

answers:

1

I am new to xpages in Lotus Notes and need to work with the "onKeyPress" Event. With the following CodeSnippet Client Side Javascript works fine.

if (thisEvent.keyCode!=13) {
      doNothing();
} 

How can I do the same for Server Sided Javascript (SSJS) ? I need to get a handle on the Event.

+2  A: 

Hi Tom,

In each event in a field on an XPage you have the option to create Client Side and Server Side Javascript. If you want to run server side code when the user presses return then in the client side then do something like:

if (thisEvent.keyCode==13) {
      return true;
}else{
      return false;
}

This will then send the keypress onto the server side event (if there is one) to execute.

In the server side event you can then get a handle onto whichever field you're working with to get the value which was submitted using either:

getComponent("myfield").getValue();

or

getComponent("myfield").getSubmittedValue();

Hope this helps.

Matt

Matt White
Thank you very much MattThis tip is very helpful
Tom