Robby Pelssers wrote:
Good point...
But how should this be implemented?
I hate working for free... but, for this once ;)
<map:flow language="javascript">
<map:script src="parent.js" />
<map:script src="child.js" />
<map:script src="test.js" />
</map:flow>
<map:match pattern="testSubclass/*/*">
<map:call function="testSubclass">
<map:parameter name="className" value="{1}"/>
<map:parameter name="name" value="{2}"/>
</map:call>
</map:match>
// parent.js
function Parent() {
this.name= "";
return this;
}
Parent.prototype.setName = function(name) {
this.name= name;
}
Parent.prototype.getName = function() {
return "Parent: " + this.name;
}
// child.js
function Child() {
return this;
}
Child.prototype= new Parent();
Child.prototype.getName = function() {
return "Child: " + this.name;
}
// test.js
function testSubclass () {
var className= cocoon.parameters["className"];
var name= cocoon.parameters["name"];
var obj= eval("new " + className + "()");
obj.setName(name);
cocoon.log.debug("XXXX " + obj.getName());
}
I did not try myself, but it should print the class name and object name
given as parameters... though Cocoon will give you an error because the
function does not return a page (I am too lazy today to provide one, sorry).
Regards,
--------------------
Luca Morandini
www.lucamorandini.it
--------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]