invokeSuper being called twice

62 views
Skip to first unread message

Taylor Williams

unread,
Sep 20, 2013, 8:38:50 AM9/20/13
to intersys...@googlegroups.com
Is there a good reason why the following Zen page will create two javascript alerts stating "Some specific rendering code"? It seems that invokeSuper ends up calling the renderContents() method twice. There are three classes in the below example:

1) extending dynaGrid
Class ZENTest.defaultGrid Extends %ZEN.Component.dynaGrid
{

/// Client-side method to render this component.
ClientMethod renderContents() [ Language = javascript ]
{
//Call to super!
this.invokeSuper('renderContents',arguments)

//Do specific code here
alert('Some specific rendering code')
}

}


2)extending defaultGrid

Class ZENTest.customerGrid Extends ZENTest.defaultGrid
{

}



3)ZEN page:

/// Created using the page template: Default
Class ZENTest.Page Extends %ZEN.Component.page
{

XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen" title="HEY">

<customerGrid id="cgTest" />

</page>
}

}




When I call this zen page I get identical two javascript alerts while I expect only one.

 If I add a renderContents method with a invokeSuper into the customerGrid class, the page acts as expected and only one alert appears. However, I wouldn't think the additional invokeSuper is necessary. Any thoughts?

Tom Rombaut

unread,
Dec 16, 2013, 10:55:13 AM12/16/13
to intersys...@googlegroups.com
I had the same problem and contacted Intersystems about it through WRC.

This was their answer:

I just heard back from development and this is expeced behavior from client methods within ZEN, at this point in time there are not plans to alter this behavior. 

Of course this is expected behavior, it's programmed that way. Is it normal OO behavior? Absolutely not. Nevertheless, a workaround was given:

Override every method in your child class that has invokeSuper calls in the superclass: 

Class ZENTest.customerGrid Extends ZENTest.defaultGrid
{
ClientMethod renderContents() [ Language = javascript ]
{
//Call to super, just because!
this.invokeSuper('renderContents',arguments)
}
}

Regards
Tom
Reply all
Reply to author
Forward
0 new messages