rafalszemraj / fabrication

Automatically exported from code.google.com/p/fabrication
2 stars 1 forks source link

ReflexiveMediatorRegistration REFLEXIVE REGISTRATION PROBLEM #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create application mediator.
2. Create application's child - panel -> TabNavigator(descendant of 
Panel) -> any number of children (descendants of TabNavigator)
3. Inside onRegister of the main app mediator, 

registerMediator(new MyMediator(this.resolve(application)..rex
("myLogs") ));

the fully qualified path would be 
appplication.myPanel.myTabNavigator.myLogs

4. MyMediator's onRegister never gets triggered even after the 
TabNavigator's child has been activated and creation complete event has 
fired.

What is the expected output? What do you see instead?
Expected to have MyMediator's onRegister call made.

What version of the product are you using? On what operating system?

Fabrication 0.6
PureMVC MultiCore 1.0.5
Utility MultiCore Pipes 1.1

Original issue reported on code.google.com by a.mikhai...@gmail.com on 10 Feb 2009 at 11:22

GoogleCodeExporter commented 9 years ago
Can you post the the exact MXML that is causing this issue? Also what version 
of the Flex SDK are you using?

Original comment by darshan....@gmail.com on 11 Feb 2009 at 4:48

GoogleCodeExporter commented 9 years ago
The Flex SDK version is 3.2.0

main application mediator:

MainAppMediator

override public function onRegister():void
{
    registerMediator(new LoginControlMediator(this.resolve(application)..rex
("loginControl") )); //works fine for this component it's path is 
application.loginControl LoginControlMediator's onRegister fires as expected
    registerMediator(new MyRunLogMediator(this.resolve(application)..rex
("myRunLogs") )); //this one never fires MyRunLogMediator's onRegister. It's 
hierarchical path is application.customPanel.tabNavigator.myRunLogs
}

I tried debugging the ComponentResolver but without success. 

If I do the following:
registerMediator(new MyRunLogMediator(this.resolve(application)..rex
("tabNavigator") )); - it works (meaning that onRegister method of the Mediator 
gets 
fired and, obviously, I get a null object coercion error since the 
viewComponent is 
of different type.

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 5:02

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
...forgot to add:

So once you switch it back from ..rex("tabNavigator") to ..rex("myRunLogs") it 
never 
fires Mediator's onRegister. 

I can set up a few break points at ComponentResolver and see what happens if 
you can 
point me in the right direction.

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 5:06

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Your registration code looks ok, Can you please post the actual MXML you are 
using. I 
tried running ..rex on some simple layouts like the TabNavigator you suggested 
which 
worked. I would like to test against your actual MXML. Thanks.

Original comment by darshan....@gmail.com on 11 Feb 2009 at 5:28

GoogleCodeExporter commented 9 years ago
My suspicion is that some event doesn't bubble up. Is framework attaching 
listeners 
to the main <fab:FlexApplication/> and listening for creationComplete from any 
descendant component, then running through a dictionary of registered mediators 
to 
instantiate mediators with component reference as oppose to ComponentResolver 
instance? Is that the logic? Which event are you listening for from the 
children 
components?

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 5:29

GoogleCodeExporter commented 9 years ago
It's a big solution (project) with a bunch of references. I'll have to 
extrapolate a 
subset specifically for this test.

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 5:31

GoogleCodeExporter commented 9 years ago
I've posted a "View Source" section, which I think is best in this situation.

http://mikhailau.com/fabrication/srcview/

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 5:42

GoogleCodeExporter commented 9 years ago
The focus is on:

view.mediators.MyRunLogMediator
view.components.tabcomponents.MyRunLog

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 5:45

GoogleCodeExporter commented 9 years ago
It would be great if you could post some mxml. Or try using only the descendant 
operators. resolve(application)..myRunLogs. 

The resolved logic is to listen for the childAdd event from the main component 
which 
gets bubbled up. Then wait for the source component to be initialized. Some 
components like Containers need coaxing where you have to locate the child by 
using 
getChildByName. This is also used when the component could already have been 
created 
at the time the registration was invoked. 

Original comment by darshan....@gmail.com on 11 Feb 2009 at 5:48

GoogleCodeExporter commented 9 years ago
I have tried using the descendant operator and got the same results. So that is 
why 
I was leaning towards the thought of the event not bubbling through.
The src is up http://mikhailau.com/fabrication/srcview/

These are the bad boys:

view.mediators.MyRunLogMediator
view.components.tabcomponents.MyRunLog

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 5:55

GoogleCodeExporter commented 9 years ago
Ok got it. Let me debug this a little.

Original comment by darshan....@gmail.com on 11 Feb 2009 at 6:06

GoogleCodeExporter commented 9 years ago
np

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 6:13

GoogleCodeExporter commented 9 years ago
Any news from debugging it?

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 1:58

GoogleCodeExporter commented 9 years ago
I have replicated the bug. But haven't found a solution yet. The childAdd event 
doesn't seem to bubble up...

Original comment by darshan....@gmail.com on 11 Feb 2009 at 3:06

GoogleCodeExporter commented 9 years ago
That was my suspicion without even going farther because a level higher 
component 
(such as tabNavigator) would work fine or any component for that matter, but 
the 
myRunLogs. Is it something to do with the TabNavigator component you think? I 
know 
it is poorly built because to pre-define the "selectedIndex" you have to 
override 
commitProperties as the tabBar never receives the value of selectedIndex... 
things 
like that. Just a thought.

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 3:11

GoogleCodeExporter commented 9 years ago
An interesting finding:

if i add "childAdd" event listener to the tabNavigator I see relatedObject 
as "myRunLogs" coming through. When I trace out each event's event.bubbles 
value, I 
get false.

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 3:46

GoogleCodeExporter commented 9 years ago
Is this the problem? (from mx.core.Container.as)

override mx_internal function childAdded(child:DisplayObject):void
    {
        dispatchEvent(new Event("childrenChanged"));

        var event:ChildExistenceChangedEvent =
            new ChildExistenceChangedEvent(
            ChildExistenceChangedEvent.CHILD_ADD);
        event.relatedObject = child;
        dispatchEvent(event);

        child.dispatchEvent(new FlexEvent(FlexEvent.ADD));

        super.childAdded(child); // calls createChildren()
    }

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 3:54

GoogleCodeExporter commented 9 years ago
If I try to force event to bubble as in mx.container.Container.as

override mx_internal function childAdded(child:DisplayObject):void
    {
        dispatchEvent(new Event("childrenChanged"));

        var event:ChildExistenceChangedEvent =
            new ChildExistenceChangedEvent(
            ChildExistenceChangedEvent.CHILD_ADD,true);
        event.relatedObject = child;
        dispatchEvent(event);

        child.dispatchEvent(new FlexEvent(FlexEvent.ADD));

        super.childAdded(child); // calls createChildren()
    }

it breaks the framework

Original comment by a.mikhai...@gmail.com on 11 Feb 2009 at 4:04

GoogleCodeExporter commented 9 years ago
I came to a similar conclusion. I am going to look at the resolver 
implementation 
over the weekend and try to figure out a better way to do deeper resolution. 

For the moment I think you may have to listen for creationComplete from the 
myRunLogs 
component and then register its mediator.

Original comment by darshan....@gmail.com on 12 Feb 2009 at 5:25

GoogleCodeExporter commented 9 years ago
any update?

Original comment by gretel....@gmail.com on 17 Jun 2009 at 12:00

GoogleCodeExporter commented 9 years ago
Hi, we are having the same issue on a quite a large project. 
Is there any change this will be fixed?

We are working around the issue now by listening to the creationComplete of the 
child ... but it would be nice if 
it would just work as you suppose ;-)

Cheers,
Frederik Jacques

Original comment by frederik...@me.com on 30 Mar 2010 at 10:50

GoogleCodeExporter commented 9 years ago
I've tried the Slaker Demo and modified it a little bit to use it with Flex 
Spark components. I found out that onRegister method is only called if I use 
the the mx components (instead of Spark). So is there any solution or fix for 
this problem?

If not can somebody please explain the creationComplete workaround described 
above?

Thanks.

Original comment by holger.s...@gmail.com on 15 Dec 2011 at 3:39

GoogleCodeExporter commented 9 years ago
Addition to former post: Also the reactTo method doesn't work with any(?) Spark 
component. I've testet it with the s:NavigatorContent in a mx:ViewStack.

Original comment by holger.s...@gmail.com on 15 Dec 2011 at 3:46

GoogleCodeExporter commented 9 years ago
In my case it works, when I replaced the mx:ViewStack with the CustomViewStack 
from the Flex 4 Cookbook 
(http://cookbooks.adobe.com/post_Creating_a_Spark_based_ViewStack-17726.html).

Original comment by holger.s...@gmail.com on 15 Dec 2011 at 4:52