/* RSence * Copyright 2006 Riassence Inc. * http://riassence.com/ * * You should have received a copy of the GNU General Public License along * with this software package. If not, contact licensing@riassence.com */ /*** = Description ** Data value synchonization container object. ** ** +HValue+ is the default class to use for data syrchronization purposes. ** It's smart enough to tell COMM.Values (Value Manager) that it has ** been changed. ** ** A single HValue instance can be bound to any number of responders, the ** main client-side responder class is +HControl+. ** ** When you change the value in one of the instances bound to the HValue ** instances, all other instances get notified too and the server is also ** notified and can be further bound on the server side to any number of ** responders there too. ** ** An instance constructed with "false" (Boolean) as its id is not reported ** to the server. Such an instance can be used for client-side responder ** synchronization. ** ** Priority-wise, only the server can create a value id. If a value id is ** created on the client, the server won't recognize nor accept it. ** ** If a value is changed on the server, it overrides the changes on ** the client, so no server-client lock is needed in this model. ** ** = Instance variables: ** +id+:: Value Id, used by the whole value management system to identify individual values. ** +type+:: '[HValue]' ** +value+:: The container/"payload" data value itself. ** +views+:: A list of Components that uses this value. ** Used for automatic value syncronization between responders. ***/ var//RSence.Foundation HValue = HClass.extend({ /** = Description * Constructs a value with the initial value +_value+ and the unique id +_id+. * * Only the server can create value id's, so use false when constructing * from the client. A value with a false id is not reported to the server. * * = Parameters * +_id+:: The source id (ideally set by server, should be unique) * +_value+:: The initial data * **/ constructor: function(_id,_value){ this.id = _id; this.value = _value; this.views = []; if(_id){ COMM.Values.add(_id,this); } }, /** Destructor method. Releases all bindings. **/ die: function(){ for(var _viewNum=0;_viewNum