Mediators stopped working all of a sudden

kamcknig's Avatar

kamcknig

25 Aug, 2015 11:59 AM

Hello!

So I've been working with RL2 for a bit now. And my project was going just fine. I was changing some views around, just changing some widths and heights and repositioning them and then all of a sudden everything just stopped working up to a certain point. My mediators no longer got created and intialized. I have literally no idea where to go to debug it. I can't even setup a simple project to show what's happening as it's specific to this project. I really dont think I cahnged anything at all having to do with the config. I have a MainView that has some children are a part of it's MXML. Some of those children are mediated. MainView gets mediated just fine. I've added and Event.ADDED listener to MainView and the children that are supposed to be mediated are added to the stage according to the traces from the ADDED handler, but the mediators for them are no longer being created! The only code I've changed was width/height/position code.

My code is also under revisiion control and I stashed all changes I had made since I knew it was working, and it is still doing the same thing. So it literally CANNOT be my code that made it stop working.

No clue where to even begin to look. If this sort of thing has happened to anyone else and you were able to fix it, please let me know!

Thanks!

Showing page 2 out of 2. View the first page

  1. Support Staff 31 Posted by Ondina D.F. on 25 Aug, 2015 02:26 PM

    Ondina D.F.'s Avatar

    Add event listeners for added to stage and creation complete for mainview, vgroup and PointOfSaleView. See (trace) if you are attempting to add children to the vgroup while it is not on stage yet.

  2. 32 Posted by kamcknig on 25 Aug, 2015 02:37 PM

    kamcknig's Avatar

    I get in order

    MainView added
    vGroup added
    PointOfSaleView added
    PointOfSaleView created
    PointOfSaleViewMediator initialized
    vGroup created
    MainView created
    MainViewMediator intialized

  3. Support Staff 33 Posted by Ondina D.F. on 25 Aug, 2015 02:42 PM

    Ondina D.F.'s Avatar

    Now, add PointOfSaleView from within your MainMediator (as you had it in your code), but instead of view.addElement(new PointOfSaleView());
    do: view.vGroup.addElement(new PointOfSaleView());

    Also put a trace statement inside the method that creates and adds the subviews, and see if it is called before vGroup is added to the stage.

  4. 34 Posted by kamcknig on 25 Aug, 2015 02:43 PM

    kamcknig's Avatar

    Things do break now with that, though the views still show up on stage unlike before, but they are all wonky

    EDIT: Before adding POS in the mediator

  5. 35 Posted by kamcknig on 25 Aug, 2015 02:46 PM

    kamcknig's Avatar

    I get

    MainView added
    vGroup added
    vGroup created
    MainView created
    MainViewMediator intiialize
    MainViewMediator display view (method that creates PointOfSaleView)
    PointOfSaleView added
    PointOfSaleView created
    PointOfSaleViewmediator initialize

    And things are still wonky but are showing up on screen

  6. Support Staff 36 Posted by Ondina D.F. on 25 Aug, 2015 02:48 PM

    Ondina D.F.'s Avatar

    Wonky? The position/layout is not as expected or what?

  7. Support Staff 37 Posted by Ondina D.F. on 25 Aug, 2015 02:49 PM

    Ondina D.F.'s Avatar

    The trace shows that when you add PointOfSaleView to the right parent it gets added to the stage and its mediator is created. So, from a robotlegs point of view everything is ok.

  8. 38 Posted by kamcknig on 25 Aug, 2015 02:50 PM

    kamcknig's Avatar

    it looks like it's all added to the stage, but the widths and heights of a lot of things seem like they must be set to 0. I can see some components that have hardcoded widths/heights but ones that use percentages seem to not be there (which i assuem in this case means their widths/heights are 0)

  9. Support Staff 39 Posted by Ondina D.F. on 25 Aug, 2015 02:50 PM

    Ondina D.F.'s Avatar

    By the way, adding subviews to a view should be View's job. So, after you make it work, you should transfer the logic from within your main mediator to the main view. MainMediator should only pass the necessary data to a MainView's API

  10. Support Staff 40 Posted by Ondina D.F. on 25 Aug, 2015 02:52 PM

    Ondina D.F.'s Avatar

    it looks like it's all added to the stage, but the widths and heights of a lot of things seem like they must be set to 0. I can see some components that have hardcoded widths/heights but ones that use percentages seem to not be there (which i assuem in this case means their widths/heights are 0)

    That's a Flex problem. Can't say why it's happening. Maybe instead of top/bottom etc, you should try x, y

    [EDIT] mx.events.FlexEvent.CREATION_COMPLETE:
    Dispatched when the component has finished its construction, property processing, measuring, layout, and drawing.
    At this point, depending on its visible property, the component is not visible even though it has been drawn.

    I'm mentioning this because it looks like some of your subviews are not dispatching the event CREATION_COMPLETE, to which robotlegs listens to in order to call mediator's initialize() method. This might have something to do with the way you're setting the layout/ positions of the views. Try to fix the layout issue.

  11. Support Staff 41 Posted by Ondina D.F. on 25 Aug, 2015 02:57 PM

    Ondina D.F.'s Avatar

    I think we solved the mediation problem, right? Can I do anything else for you?

  12. 42 Posted by kamcknig on 25 Aug, 2015 03:00 PM

    kamcknig's Avatar

    Ok. So.... how does this help with adding Child1/2 in the previous structure to a VGroup? lol. I'm sorry for being dense. Buuuuut none of this illustrates any points to me :/

  13. Support Staff 43 Posted by Ondina D.F. on 25 Aug, 2015 03:08 PM

    Ondina D.F.'s Avatar

    The point is, that you should add children to a View or a subview (vgroup) first after they have a stage property. Also, that you should add children to the right container.
    When views are added to the stage, as it was the case with PointOfSaleView at last, their mediator is created and initialized.
    The traces show that it worked well for PointOfSaleView, and if you follow the same logic, it will work for any other subview. I don't know where and how you add the child1 to 4, so I can't tell you how to proceed.

  14. Support Staff 44 Posted by Ondina D.F. on 25 Aug, 2015 03:51 PM

    Ondina D.F.'s Avatar

    Last question for today:

    I actually wanted to ask it earlier, but I got carried away by your messages.
    It seems like MainMediator is able to listen to the DisplayViewEvent.DISPLAY_VIEW event, since the traces show the PointOfSaleViewmediator initialize, but just for the sake of completeness :

    From where and when are you dispatching DisplayViewEvent.DISPLAY_VIEW?

    Is the MainMediator already initialized by the time you dispatch the event?
    Are the mappings for the subviews completed by the time you dispatch the event?

  15. 45 Posted by kamcknig on 25 Aug, 2015 03:58 PM

    kamcknig's Avatar

    The AppMediator mediates my document class and listens for a BootStrap complete event which then adds the MainView to the WindowedApplication view. When the MainViewMediator is initialized it tells MainView to add a LoginView to itself. When the user logs in a LOGIN event is dispatched which that MainViewMediator catches and tells it's view to remove the LoginView. I then have a PostLoginCommand that runs also which dispatches the DisplayView event at which point the MainViewMediator tells creates the PointOfSaleView to add to MainView.

  16. Support Staff 46 Posted by Ondina D.F. on 25 Aug, 2015 04:05 PM

    Ondina D.F.'s Avatar

    Alright. In this case there is really nothing wrong with the robotlegs part of things.
    I don't know what is still unclear to you or what is not working, besides the Flex layout thing....

  17. Support Staff 47 Posted by Ondina D.F. on 25 Aug, 2015 10:14 PM

    Ondina D.F.'s Avatar

    The following links are about flex components and their lifecycle. I thought they might help you figure out how to make sure that the subcomponents fire the creation complete event, which, as I said, is needed to trigger mediator's initialize() method.

    http://help.adobe.com/en_US/flex/using/WS460ee381960520ad-2811830c1...

    http://www.developmentarc.com/site/wp-content/uploads/pdfs/understa...

    http://www.dlgsoftware.com/primers/Primer_on_Flex3_Component_Lifecy...

    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c...

    From the above article:
    "creationComplete Dispatched when the component, and all its child components, and all their children, and so on, have been created, laid out, and are visible.
    Flex dispatches the creationComplete event for a container when those children that are initially required are fully processed and drawn on the screen, including all required children of the children, and so on. Create a listener for the creationCompleteevent, for example, if you must have the children’s dimensions and positions in your event handler. Do not use the creationComplete event for actions that set layout properties, as doing so results in excess processing time."

    Also see if itemcreationpolicy set to imediate changes the behaviour of your child- components.

  18. 48 Posted by kamcknig on 26 Aug, 2015 01:22 AM

    kamcknig's Avatar

    Thanks for gathering the links!

  19. Support Staff 49 Posted by Ondina D.F. on 28 Oct, 2015 03:51 PM

    Ondina D.F.'s Avatar

    I hope you found a solution for your Flex problem. Closing this discussion for now. You can re-open it, if need be.

  20. Ondina D.F. closed this discussion on 28 Oct, 2015 03:51 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac