« Back to home

Passing document data objects to XPages custom controls

Perhaps unfortunately, custom controls inherit the scope and variables of the XPages they are placed on. The upside of this is that you can bind data to document1 on an XPage, and then refer to document1 in custom controls on that XPage. The downside is that if you define a variable in an XPage (such as a data source), and then define it in the custom control as well, the two will clash.…

Read more »

JavaScript function syntax revisited

A commenter pointed out that my previous posting on function in JavaScript missed out some subtle differences between function as a way to create lambdas which are assigned to variables, and function as a statement which creates a function variable. The function statement actually has one benefit: Functions defined using it are lifted to the top of the context which contains them. This means you can refer to them before you define them.…

Read more »

The whys of Unobtrusive JavaScript

The HTML standards provide attributes on many elements, enabling you to set them up to call JavaScript when an event occurs. For example, a text field might use the onchange attribute to call some JavaScript to trim whitespace from the beginning and end of the value: <input type="text" id="field1" name="username" onchange="trim(‘field1’);"> However, this method of working has gradually become unpopular. Instead, most now seem to recommend setting up all the events on a page using a JavaScript routine; a practice called unobtrusive JavaScript.…

Read more »