You kind of can't add event handlers to a class. The compiler uses a
special mechanism to pass them to the runtime. For future reference, you
can obtain a reference to your instance's prototype thisayway:
    this.constructor.prototype

but it sounds like what you really want is to make a new class at
runtime. This is possible in our current implementation, but not
documented or encouraged. Tucker, we should consider this a feature
request to make the new class system (in Legals) public.

A

On Jun 12, Matthew Cloy wrote:

> Hi,
> 
> I want to inject event handlers into a class prototype (not instance) at 
> runtime. (specifically into the prototype of view, but would be useful 
> to do
> in other circumstances too, and would be useful to also be able to 
> inject functions and attributes!!!)
> 
> Why?
> 
> Our application is SOLO, but entirely dynamically built.
> 
> I've modified LzView to request child nodes from the server under 
> certain circumstances.
> 
> (I.E, views (and actually datasets too) can be sent in XML from our 
> server to a dataset in the app, and the UI is dynamically generated in a 
> SOLO application from this. A little like a limited proxied mode without 
> the servlet)
> This xml very closely matches the xml one would use to define a .lzx 
> file, but without any JS, methods or constraints (For obvious reasons), 
> but there are other constructs in our code base that accomodate layouts 
> and "actions".
> 
> This all works lovely now.
> 
> BUT, I don't want to have to modify the core laszlo code or components.
> 
> I figure I just need to inject a default oninit event handler to the 
> prototype of <view> at startup, but how?
> 
> I had a poke around at the prototype of the view class in the debugger 
> (LzView.prototype), and tried changing a few things
> (like the default x coordinate for a view, and the default bgcolor) but 
> newly created views didn't inherit my change, so I just gave up
> and modified the source.
> 
> Any help appreciated.
> Thanks
> Matt
> 
> 
> _______________________________________________
> Laszlo-user mailing list
> [email protected]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
> 
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user

Reply via email to