Saturday, August 14, 2010

Couple of things for Mike

Double brace initializers:
http://stackoverflow.com/questions/924285/efficiency-of-java-double-brace-initialization

The JSON technique is really simple... use a handrolled or library JSONBuilder on the server to spit JSON onto the client, include some JS which on DOM-load replaces some div's innerhtml with HTML rendered from the JSON. Hang observers off it (remembering not to actually observe until you've set the innerhtml, so the tags exist) and regenerate the whole shaboodle any time the data changes. Never manipulate the generated HTML.

It's great for complex widgets (a smart table) and equally good for making simple widgets smart. For example, restricting the options available in a select according to a mapping from some other select's current value.

No comments: