Monday, February 14, 2011

Small update on the EventDelegator demo - onChange implemented

I don't know if anyone is using my EventDelegation technique for custom events.

In case any of you do, I've updated the demo/script in the demoapp. You can now also delegate onChange events.

Thursday, February 10, 2011

XPages: dojo performance tip

This tip is most valid if there's a big difference between edit mode and read mode.

You can compute if dojo modules are rendered the same way you compute any other component.
E.g. in this.resources (source mode):
<xp:dojoModule name="dijit.Editor" rendered="#{javascript:return currentDocument.isEditable();}" />
In one of my XPages the read mode has 17 requests, and the edit mode has 56 requests.

I don't notice much difference, as I'm on a decent line with low latency, but for users with low bandwith/high latency the difference can probably be highly noticable.

XPages: RichTextEditor + custom partial refresh + validation error = lost content

I ran into a problem today with content disappearing from a rich text editor when there was a validation error/saving. I did a little investigation, and it turns out that the RichTextEditor has a submitListener that updates a hidden field. This hidden field is used by the server to set the field/scope value on the server (at least it looks that way).

When my custom partial refresh ran, the hidden field didn't have a value. When combined with a validation error, this resulted in an empy RichTextEditor after refresh.

To work around this problem, I run the code (CSJS) below before running any "custom" partial refreshes:
// Process any autogenerated submit listeners
if( XSP._processListeners ){ // Not sure if this is valid in all versions of XPages
 XSP._processListeners( XSP.querySubmitListeners, document.forms[0].id );
}
This code won't work if you have multiple forms. Then you'd have to write a loop that calls the method once per form.

Thursday, February 3, 2011

Domino Designer setting that cleans up whitespace in XPage source


(Clear all blank lines)

Press Ctrl+Shift+F to autoformat code. With the above setting in place, you also should get rid of blank lines.

Share and enjoy!