|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
getCacheUsage suggestionThe Helma documentation indicates that getCacheUsage is the name to use
to get the number of nodes in the application cache. To use in a javascript function, the method uses getCacheusage(). It appears that either the documentation is incorrect or 'ApplicationBean.java' needs to be changed to capitalize the 'U' to so that getCacheUsage is defined. Thanks, Kris _______________________________________________ Helma-user mailing list Helma-user@... http://helma.org/mailman/listinfo/helma-user |
|
|
__defineGetter__ for existing HopObject propertiesHi,
I can't use __defineGetter__ for properties of a HopObject, which are defined in type.properties, can I? The first quick tests show that the getters or setters are ignored but I don't know if this is the way it's supposed to be... Thanks! Walter _______________________________________________ Helma-user mailing list Helma-user@... http://helma.org/mailman/listinfo/helma-user |
|
|
Re: __defineGetter__ for existing HopObject propertiesWalter Krivanek, VividVisions wrote:
> I can't use __defineGetter__ for properties of a HopObject, which are > defined in type.properties, can I? Looks like no. Which is at odds with the treatment of standard properties. E.g., in Rhino and Firefox 2, a = { a:'hi' }; a.__defineGetter__('a',function(){ return 'bye'; }); a.a; the above code returns "bye". But apparently in Firefox 3 you'll have to delete a.a first before you can define a getter for it (which makes sense to me). I don't know if that works with HopObjects, and I also don't know if it would result in that property actually being deleted. You can't access the stored value of the original property from the getter anyway, so trying to overload the actual property seems like a bad idea to me. In one case where I've needed a getter/setter (stored the value in the DB as an Int unix timestamp, wanted to work with it as a Date object) I just named the property .modified_ and wrote my getters and setters for .modified. -Joshua _______________________________________________ Helma-user mailing list Helma-user@... http://helma.org/mailman/listinfo/helma-user |
|
|
Re: getCacheUsage suggestionOn Nov 13, 2007, at 18:48 , Kris Leite wrote: > The Helma documentation indicates that getCacheUsage is the name to > use > to get the number of nodes in the application cache. To use in a > javascript function, the method uses getCacheusage(). It appears that > either the documentation is incorrect or 'ApplicationBean.java' > needs to > be changed to capitalize the 'U' to so that getCacheUsage is defined. Thanks... for now, I'm fixing it in the documentation. Chris _______________________________________________ Helma-user mailing list Helma-user@... http://helma.org/mailman/listinfo/helma-user |
|
|
Re: __defineGetter__ for existing HopObject propertiesHi,
Almost a year later, here a patch that gets this to work. http://helma.org/bugs/show_bug.cgi?id=647 With this in place, we can do neat things like adding support for watch / unwatch to HopObjects: HopObject.prototype.watch = function(prop, handler) { this.__defineGetter__(prop, function() { this.unwatch(prop); var value = this[prop]; this.watch(prop, handler); return value; }); this.__defineSetter__(prop, function(value) { this.unwatch(prop); var ret = handler.call(this, prop, this[prop], value); if (ret !== undefined) value = ret; this[prop] = value; this.watch(prop, handler); }); } HopObject.prototype.unwatch = function(prop) { delete this[prop]; } I am curious to find out if this can make it into Helma 1.6.3 (or later). Jürg On 20 Nov 2007, at 18:10, Joshua Paine wrote: > Walter Krivanek, VividVisions wrote: >> I can't use __defineGetter__ for properties of a HopObject, which are >> defined in type.properties, can I? > > Looks like no. Which is at odds with the treatment of standard > properties. E.g., in Rhino and Firefox 2, > > a = { a:'hi' }; > a.__defineGetter__('a',function(){ return 'bye'; }); > a.a; > > the above code returns "bye". But apparently in Firefox 3 you'll > have to > delete a.a first before you can define a getter for it (which makes > sense to me). I don't know if that works with HopObjects, and I also > don't know if it would result in that property actually being deleted. > > You can't access the stored value of the original property from the > getter anyway, so trying to overload the actual property seems like a > bad idea to me. In one case where I've needed a getter/setter (stored > the value in the DB as an Int unix timestamp, wanted to work with it > as > a Date object) I just named the property .modified_ and wrote my > getters > and setters for .modified. > > -Joshua > _______________________________________________ > Helma-user mailing list > Helma-user@... > http://helma.org/mailman/listinfo/helma-user _______________________________________________ Helma-user mailing list Helma-user@... http://helma.org/mailman/listinfo/helma-user |
| Free embeddable forum powered by Nabble | Forum Help |