This did the magic. I'll look at the "apply" code to understand it better.

Thx, thx, thx 😝



Hiedra



-----Mensaje original-----
De: Greg Dove <greg.d...@gmail.com<mailto:greg.d...@gmail.com>>
Enviado el: lunes, 2 de diciembre de 2024 3:21
Para: dev@royale.apache.org<mailto:dev@royale.apache.org>
Asunto: Re: Parameters of type paramArray



perhaps try :

itemFilter = imodel.itemFilterDefault.apply( imodel  ,args); //



On Mon, Dec 2, 2024 at 3:08 PM Maria Jose Esteve 
<mjest...@iest.com<mailto:mjest...@iest.com>> wrote:



> Ok, I know when the error occurs specifically, but I don't know if

> this implementation "should work" or if it is just not implemented well.

> "Exception occurred: TypeError: Cannot read properties of undefined

> (reading 'apply')" occurs when the function call "...args" belongs to

> an "Interface".

> (I have put together this simplified example)

>

> public class Controller extends EventDispatcher implements

> IBeadController {

>         ....

>         protected var _model:IBeadModel;

>

>         protected function get imodel():IModelArqManager

>         {

>             return MasterConfigSystemModel (_model);

>         }

>         ....

>         protected function

> checkFilterDelegate(itemFilter:ICTypeArqParams,

> ... args):ICTypeArqParams

>         {

>             if(!itemFilter){

>                 if(imodel.filterOn && imodel.currentItemFilter!=null)

>                     itemFilter = imodel.currentItemFilter.clone();

>                 else

>                     itemFilter =

> imodel.itemFilterDefault.apply(this,args); // [0] (Definition in the

> Interface [2])

>             }

>             itemFilter.fieldOrder = imodel.currentFieldSort;

>             return itemFilter;

>         }

> }

>

> I have a Base Model:

> public class ModelArqManager implements IModelArqManager {

>         ...

>         public function itemFilterDefault(... args):ICTypeArqParams {

>             var item:ICTypeArqParams =

> retriveNewItemFilterDefault.apply(this, args); // ERROR when called

> from [0..1]

>             if (pagination) {

>                 item.pageSize = pageSize;

>                 item.pageIndex = -1;

>             }else{

>                 item.pageSize = -99;

>                 item.pageIndex = -99;

>             }

>             return item;

>         }

>         public function retriveNewItemFilterDefault(...

> args):ICTypeArqParams{ return null; }

>         public function retriveNewItemFilter(...

> args):ICTypeArqParams{ return null; }

>

> }

>

> And an extended Model:

> public class MasterConfigSystemModel extends ModelArqManager {

>         override public function itemFilterDefault(...

> args):ICTypeArqParams {

>             return super.itemFilterDefault.apply(this,args) as

> CTypeParMasterConfigSystem; // [1]

>         }

>         override public function retriveNewItemFilterDefault(...

> args):ICTypeArqParams

>         {

>         var idMaster:int = 0;

>         if(args.length != 0)

>              idMaster = int(args[0]);

>             return new CTypeParMasterConfigSystem(idMaster,

> pagination, pageSize);

>         }

>         override public function retriveNewItemFilter(...

> args):ICTypeArqParams

>         {

>             return retriveNewItemFilterDefault.apply(this,args); //

> This call DOES NOT PRODUCE ERROR

>         }

>

> }

>

> [2] The "itemFilterDefault" function is defined in the Interface:

>         public interface IModelArqManager {

>                 ...

>                 function itemFilterDefault(... args):ICTypeArqParams;

>                 ...

>         }

>

> Thx.

> Hiedra

>

> -----Mensaje original-----

> De: Josh Tynjala 
> <joshtynj...@bowlerhat.dev<mailto:joshtynj...@bowlerhat.dev>> Enviado el: 
> lunes, 2 de

> diciembre de 2024 0:09

> Para: dev@royale.apache.org<mailto:dev@royale.apache.org>

> Asunto: Re: Parameters of type paramArray

>

> That is the way that I would have suggested to call other functions.

> Perhaps this means that there is a bug in the compiler.

>

> Does this work?

>

> var item:ICTypeArqParams =

> this.retriveNewItemFilterDefault.apply(this,args);

>

> --

> Josh Tynjala

> Bowler Hat LLC <https://bowlerhat.dev>

>

>

> On Sun, Dec 1, 2024 at 2:13 PM Maria Jose Esteve 
> <mjest...@iest.com<mailto:mjest...@iest.com>>

> wrote:

>

> > Thanks Josh, I understand the concept you are showing me. The

> > problem I have now, as I mentioned in my previous email, is that it

> > does not allow me to use apply with calls to functions external to the 
> > override:

> >

> > public function itemFilterDefault(... args):ICTypeArqParams {

> >         // I can't implement it like this because I get an error

> > "retriveNewItemFilterDefault is not a function"

> >         var item:ICTypeArqParams =

> > retriveNewItemFilterDefault.apply(this,args);

> >          if (pagination) {

> >                  item.pageSize = pageSize;

> >                  item.pageIndex = -1;

> >         }else{

> >                  item.pageSize = -99;

> >                  item.pageIndex = -99;

> >          }

> >          return item;

> >  }

> > public function retriveNewItemFilterDefault(...

> > args):ICTypeArqParams{ return null; } // This function is the one

> > that will normally be overridden in child classes

> >

> > In these cases, is there another way to do it?

> > Thx.

> > Hiedra

> >

> > -----Mensaje original-----

> > De: Josh Tynjala 
> > <joshtynj...@bowlerhat.dev<mailto:joshtynj...@bowlerhat.dev>> Enviado el: 
> > domingo, 1

> > de diciembre de 2024 21:50

> > Para: dev@royale.apache.org<mailto:dev@royale.apache.org>

> > Asunto: Re: Parameters of type paramArray

> >

> > super.fn_hello.apply(this, [index].concat(args));

> >

> > Alternatively, you can modify the args array.

> >

> > args.unshift(index);

> > super.fn_hello.apply(this, args);

> >

> > --

> > Josh Tynjala

> > Bowler Hat LLC <https://bowlerhat.dev>

> >

> >

> > On Sun, Dec 1, 2024 at 6:12 AM Maria Jose Esteve 
> > <mjest...@iest.com<mailto:mjest...@iest.com>>

> > wrote:

> >

> > > Perfect Josh, thanks.

> > >

> > > When the paramArray is, for example, the second parameter, what

> > > would that look like?

> > > For example:

> > > override protected function fn_hello(index:int, ... args){

> > >         // These are the tests I have done but none of them work for me

> > >         super.fn_hello.apply(index,args);

> > >         super.fn_hello.apply(index,[this].concat(args)); // Add "this"

> > > and, for example, index 0 is not the first parameter of args but

> > > "this" (as expected)} ,,,

> > >

> > > Hiedra

> > >

> > > -----Mensaje original-----

> > > De: Josh Tynjala 
> > > <joshtynj...@bowlerhat.dev<mailto:joshtynj...@bowlerhat.dev>> Enviado el: 
> > > viernes,

> > > 29 de noviembre de 2024 18:14

> > > Para: dev@royale.apache.org<mailto:dev@royale.apache.org>

> > > Asunto: Re: Parameters of type paramArray

> > >

> > > I think that this should do what you want:

> > >

> > > super.reevalAccesControl.apply(this, args);

> > >

> > >

> > > --

> > > Josh Tynjala

> > > Bowler Hat LLC <https://bowlerhat.dev>

> > >

> > >

> > > On Thu, Nov 28, 2024 at 7:26 AM Maria Jose Esteve

> > > <mjest...@iest.com<mailto:mjest...@iest.com>>

> > > wrote:

> > >

> > > > Hi, I've always faced this problem, but I don't know how to give

> > > > a definitive solution.

> > > > Parameters of type paramarray increase their nesting from one

> > > > call to another, for example:

> > > >

> > > > Public class ControllerFirst extends ControllerBase {

> > > >                 ...

> > > >                 private function fnmove():void{

> > > >                                var foo:String = "hello";

> > > >                                 reevalAccessControl(foo);

> > > >                 }

> > > >                 ...

> > > > override protected function reevalAccessControl(... args):void{

> > > >                 // In the first call, from fnmove "arguments"

> > > > you have an element [0] with a value "hello"

> > > >                 super.reevalAccesControl(args);

> > > >                 ...

> > > > }

> > > > }

> > > >

> > > > Public class ControllerBase

> > > > {

> > > > ...

> > > > protected function reevalAccessControl(... args):void{

> > > >                 // When this function is called from

> > > > ControllerFirst arguments has an element [0] but this element in

> > > > turn is an array of

> > > > 1 element and the value "hello" is found in args[0][0] on a

> > > > second

> > level

> > > >                 ...

> > > > }

> > > > ...

> > > > }

> > > >

> > > > I don't know if I have explained myself... I understand why it

> > > > happens but I wonder if there is a way to pass this type of

> > > > arguments so that the nesting level 0 is respected and a level

> > > > is not

> > added for each call.

> > > >

> > > > Thx.

> > > > Hiedra

> > > >

> > > >

> > >

> >

>

Reply via email to