I posted before about some weirdness with the onClick event code firing at page load time. I determined that if you edit the onclick event from the All Properties tab that you'll get this kind of behaviour. Well, here's another one.
The scenario, on the XPages Calendar, Day view I've got the normal navigation links at the top of the page to navigate forward/back a day. I'm using the dojo.gfx package to place day entries on the page (and making some decent headway by the way). On the day view page (ccCalDay) I've included a client side javascript library that contains the function which gathers data embedded on the page (Thanks Jeremy) and then places the dojo.gfx objects where they should go. Now, in the function which gets called for the dojo.addOnLoad event I get a node list of all the "calEntry" tags and their children using dojo.query. I then loop through each node and grab the "value" listed for that node. Simple enough, however the dojo.query call breaks the onclick of my navigation links.
Here's the code I placed in the Source of my ccCalDay custom control:
Now, for the function I just had:
Now, I know you're saying I must be doing something strange for this to be happening. Maybe I am, but I don't think I am, the code really isn't that complex. I set quite a few variables, build the gfx objects and that's it. I'm posting this because to me it's starting to show a pattern that the onclick event is flakey (that's a technical term by the way) at best. At worst it creates time consuming problems that don't make sense and are difficult to troubleshoot. While I know XPages are just starting to come into their own and are young but shouldn't these types of issues have already been found and addressed somewhere? Surely IBM and a lot of the business partners that get to see this stuff before it's released have run into some of these same types of issues? I say this because they build far more complex applications than myself that are tested and tested some more.
But here's how I got around this frustrating, time sucking issue. I went back to Julian Buss's XPages Wiki and this article to back track a little bit and put the addOnLoad back to how I originally had it and then added the calEntries call here instead of in the function. Here's what I ended up with in the Source of the ccCalDay custom control:
And the function now contains:
This seems to have corrected the problem but man what a headache. I'm not sure if this happened because of my inexperience with dojo and javascript or what. But I still think that the onclick event of links needs to be inspected a little bit more at IBM.