MVC pattern with YUI reviewed

I updated the Temperature Example, described in my previous post, using YAHOO.util.AttributeProvider.

Now the example is quite far away the original one. The legacy code for the MVC pattern is gone: AttributeProvider and Attribute substitute GenericDocument and DocumentItem at all.

It seems YUI support natively the MVC pattern.

I modified the document, TemperatureDocument: now it inherites from AttributeProvider.

Then I modified the view, TemperatureView.

setTemp() calls the conversion routines and updates the fields, firing the change events. Truly, these lines are not changed.

setAttributeConfig() adds the attribute to the model. In the previous code it was done by get() call, creating the attribute automagically if it didn't exist.

Then, after retrieving the attribute from the document model, I add an event handler: the event is created on the fly. Remember to add 'Change' string to the event, because setValue() call of the attribute will fire an event called with name plus 'Change'.

I added the check between previous and new value to stop circular (and infinite) field updating.