I saw that the combobox has several properties for events under all properties. I tried adding
#{compositeData.onchange} to the onchange event, and it works. One caveat is that it seems to fire three times, but I can live with that.
To implement:
Add custom properties to the custom control for the events you want to have custom event handlers for. In the source code of the field, add attributes for the events you want code to run. E.g. onchange="#{compositeData.onchange}"
In the XPage under custom properties for the custom control, write the SSJS you want to run for your events.
That's about it.
I have only tested this with ComboBoxes, but I'm not surprised if it works for most fields that have event properties.
Tested on server running Domino 8.5.2 FP2
3 comments:
Tommy,
I blogged about it a while ago.
http://lotusnotus.com/lotusnotus_en.nsf/dx/lesson-of-the-day-i-need-to-learn-more-about-xpages.htm
You may define the parameter like;
return function handler() {blah blah }
it would work then. It's not a cool solution but works.
I considered that approach after I saw what happened. The code has to run in the scope of a document data source in a repeat control, so if nothing else works, I'll have to get dirty :S
I found a way to implement the "hack" in a way that hopefully readable for future developers of my applications.
I use a Fn postfix on the custom property, and in Description, "Function...".
E.g.
onchangeFn
"Function to run in the onchange event"
Post a Comment