[Laszlo-user] overridding core class by inclusion
Pierre Augier
pierre.augier at inrialpes.fr
Wed Jul 11 05:42:21 PDT 2007
This is interresting .. i have to understand the core mechanism of OL :)
so i have few questions again :
1) Do you know where are theses core JS library (ex LzView) in the LPS
server ? i didn't find them under /lps tree.
1bis) =>And who is doing the binding from LZX code to ECMA code ? i
guess it's the OL compiler / servlet couple ?
2) Which object framework is used by OL ? prototype.js ?
another question about HCI design:
-3) Is it possible to have a MVC mechanism in OL ? I was thinking about
declaring static my component in a sort of view, bind them in a JS
library playing the role of the Controler, and then a model.
an example with a button that init and connect to a rtmp server (it's a
draft)
-------------------------------------------------------------------------
<!-- the "view" myapp.lzx-->
<canvas>
<edittext id="edittextServerAddress" />
<button id="mybutton" >connect</button>
<script src="mycontroler.js">
...
<canvas/>
-------------------------------------------------------------------------
<!-- the "controler" mycontroler.js -->
//creating the model, ideally, the view would be created here too, but
the view is the app entry point so i guess it have to be created first
and then the view have to create the controller
var rtmpconn = new myrtmpconnection();
// binding view to controler
mybutton.onclick = function(button)
{
button.setAttribute('text','connecting ...');
rtmpconn.setAttribute ... etc
rtmpconn.myModelInitMethod(edittextServerAddress.text);
rtmpconn.connect();
}
// "controller classic" functions callable from "external"
function init(adress){
... code ...
rtmpconn.myModelInitMethod(adress);
... code ...
}
-------------------------------------------------------------------------
<!-- the model "mymodel.lzx" -->
<library>
<class name="myrtmpconnection" extends="rtmpconnection">
<attribute name="myModelVar" />
<method name="myModelInitMethod" args="adress"=> (code) </method>
</class>
</library>
... hope that is clear ... the idea is to have a "real" agent MVC model
... but that's maybe a bad/wrong way ?
thanks a lot
Pierre
Henry Minsky a écrit :
> I should add that there is a certain magic translation of core class
> names
> from LZX to Javascript that is happening, so <view> actually
> corresponds to
> the real class named LzView, same for most of the core classes that are
> user visible. The magic happens via the static var declaration in a
> class called "tagname":
>
> class LzView extends LzNode {
> static var tagname = 'view';
> ..
>
>
> As Tucker said, if you redefine a core class like that, you do so at
> your own risk,
> all sorts of things will probably break.
>
> On 7/10/07, *P T Withington* <ptw at openlaszlo.org
> <mailto:ptw at openlaszlo.org>> wrote:
>
> Welcome to dynamic languages. Yes, it is allowed. If you really
> wanted to, you could replace the core classes too. And, yes, it will
> probably cause a problem if you do.
>
> In general, Javascript emphasizes flexibility over safety. IMO, Java
> leans the other way.
>
> On 2007-07-10, at 13:29 EDT, Pierre Augier wrote:
>
> > I all !!
> >
> > i 'am asking if it's possible to override core class by inclusion
> >
> > i mean something like this :
> > ----------------------------------------------------
> >
> > #file /mypath/view.lzx
> >
> > <class name="view">
> >
> > // my own view class
> >
> > </class>
> >
> >
> > and later...
> >
> > #file /myotherpath/myapp.lzx
> >
> > <include href="/mypath/view.lzx"/>
> >
> > <canvas>
> >
> > <!-- use of the overrided class -->
> > <view name="lalala" />
> >
> > </canvas>
> >
> > ----------------------------------------------------
> >
> > I've tried with "view" and "text" as class name ==> does
> > not work (compilation error)
> > then i've tried with "menu" or "button" ==> it
> > work althought i get a warning message in debug console
> >
> > i guess it's because view and text are in the LFC, but menu and
> > button are component ...
> >
> > but my question is:
> >
> > except for LFC that sems impossible to override, for the other
> > class, is this allowed ?? will cause problem ???
> >
> >
> > thanks
> >
> > Pierre
> >
> >
>
>
>
>
> --
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com <mailto:hminsky at laszlosystems.com>
>
More information about the Laszlo-user
mailing list