Sunday, September 13, 2009

Dynamically binding server side events in XPages - Is it possible?

Update, 01.05.10: Yes it's possible!

I'm currently going through a TLCC course on XPages. While doing so, I become more and more impressed with the platform (and how detailed the course is).

Having "everything" computable leads me to believe that XPages is the one and only platform to build future web applications on the Lotus platform. The Lotus Domino<8.5 platform is great, but it's starting to show its age. For new developers starting on the "old" platform, there are a lot of strange limitations to get used to. Some limitations (32k/64k being one of the most irritating for myself) will still be present due to the NSF being the storage, but a lot of doors have been opened up.

Getting on to the topic at hand. With LotusScript, you have some NotesUI events you can bind dynamically. By dynamic binding, I mean binding events outside the design element that the events occur.

I work very little with Notes Client applications, so I don't know if the LS binding is very useful. With web applications on the other hand, it's great. All application code can be stored/maintained in one (or more) JS library.

If something isn't working on a web application that uses dynamic event binding, you only have to look one place to find and correct the error. You avoid having to dig through fields, HTMLHead statements, subforms, etc.

My question: Is there an API in XPages you can use to bind events on components/the XPage itself dynamically (outside the XPage design element), using a server side JS library?

E.g.
// When the XPage is ready to be sent to the browser, bind relevant events
view.addEvent( 'afterRenderResponse', bindCustomerEvents );

function bindCustomerEvents(){
// When the value in the zip-code field changes, get the corresponding
// city-value from server, and do a partial refresh.
var zipField = getComponent( 'zip' );
zipField.addEvent( 'change', function(){
getComponent( 'city' ).fireEvent( 'partial-refresh' );
});
}

2 comments:

NotesSensei said...

The short answer: NO.
The long: it is somewhere on the list.

Tommy Valand said...

I like the long answer better than the short.. :)