Solved

Pop Ups & PureMVC woes

Posted on 2009-04-08
19
614 Views
Last Modified: 2013-11-11
I asked a question early today. Located here. I thought it solved my problem with the Flash Event, but after trying multiple times. The problem still exists. My list is populated with data on the first opening of the pop up, but every time you open it afterwards, it's empty.

Here is the constructor, and case statement that is executed after the pop up is opened.

And this is the original post. Extremely frustrated....
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Flex/Q_24306064.html

//CONSTRUCTOR: _onGetColumns retrieves the columns from another component successfully after pop up opened

public function ManageColumnsMediator(viewComponent:Object)

{

	super( NAME, viewComponent );

	viewComponent.addEventListener(FlexEvent.CREATION_COMPLETE, _onGetColumns);

	

}
 

//CASE statement in mediator that executes after columns are retreived successfully
 

case ApplicationFacade.COLUMNS_RETRIEVED:

	trace("Got Columns"); //JUST TO MAKE SURE I MAKE IT TO THIS CASE STATEMENT AFTER POP UP OPENED (TRUE)

	var list:List = new List();

	var cols:Array = new Array();

	cols = note.getBody() as Array;

	list.dataProvider = cols;

	list.labelField = cols.headerText;

       trace(mx.utils.ObjectUtil.toString(col));  //THIS PRINTS ALL THE DATA EACH TIME

	manageColumns.addChild(list);	

	break;
 

//GETTING VIEW COMPONENT

public function get manageColumns():ManageColumns

{

	return viewComponent as ManageColumns;

}

Open in new window

0
Comment
Question by:hallikpapa
  • 8
  • 8
  • 3
19 Comments
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Just a question:

>> manageColumns.addChild(list);

is it needed to build up that (=the content of the popup window) every time?
Can't you build it up once and then for all other times just alter the list's dataprovider?
0
 

Author Comment

by:hallikpapa
Comment Utility
No, I didn't think so. I had tried it like that based on an expert's suggestion. Originally I just had an  in my view component with cols being my dataProvider there. It's the same problem, it is showing the data in my trace after CREATION_COMPLETE is fired, but not in the list; only the first time.
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
can I see _onGetColumns?
0
 

Author Comment

by:hallikpapa
Comment Utility
sure
private function _onGetColumns(fe:FlexEvent):void

		{

			trace("getting columns");

			this.sendNotification(ApplicationFacade.RETRIEVE_COLUMNS);

		}

..

...

...

...

...

case ApplicationFacade.RETRIEVE_COLUMNS:

		   			var col:Array = this.analyticsView.reportsGrid.columns;		   			

		   			this.sendNotification(ApplicationFacade.COLUMNS_RETRIEVED, col);

		   			break;

Open in new window

0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
So you send the retrieved columns with the notification
>> this.sendNotification(ApplicationFacade.COLUMNS_RETRIEVED, col);

And here
>> cols = note.getBody() as Array;
you get them out.
Are you sure that here they are available?

What does getBody() looks like?
0
 

Author Comment

by:hallikpapa
Comment Utility
It's a trace/dump of the col array that was sent. I went through and checked and all the columns are there. I also hit a breakpoint in Flex Builder and it is displaying everything correctly. I am using the most current version of PureMVC, but not the multi core one if that means anything
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Running out of ideas to help. Sorry.
0
 

Author Comment

by:hallikpapa
Comment Utility
Yeah, I am going to abandon the pop up, and just do it in a panel on the right. It works great that way.

How about this. I have put this list in a panel to the right of the grid. I can drag it open and closed, but is there some component that will "snap" it open and closed?

I have seen collapsible menus, but they are horizontal. I would like to make it vertical, along the right side of the screen.
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
>> is there some component that will "snap" it open and closed?
We made our own OurHDevidedBox (extending HDevidedBox) and OurBoxDivider (extending BoxDivider) having that functionality
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
Comment Utility
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
0
 

Author Closing Comment

by:hallikpapa
Comment Utility
I like this much better. Thanks!
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Thanx 4 axxepting
0
 
LVL 5

Expert Comment

by:Fuzzy_Logic_
Comment Utility
I realise that you are dropping the popUp window, but its bugging me why the popUp is not being populated.

My line of thinking at the moment is that an object gets added to the popUp everything works fine initially. When you close the popUp this object is left stranded, this stranded object receives the 'columns' but a new blank object gets added to the popUp.
 
0
 

Author Comment

by:hallikpapa
Comment Utility
Trust me. It's bugging me too. I have another app I was trying to accomplish the same thing. And it behaves in the exact same manner. First initial pop up it works fine. Every time it opens afterwards, it is blank.

The really puzzling thing is the final step, after the pop up is created, I am populating/tracing the dataProvider. And it's all there.

The ONLY thing I can think of is I had a problem similar to this with an older version of PureMVC (I am using the current build though). And this one function that dealt with a pop up would not let me set it without passing the data, and retrieving through notification.getBody() in a switch statement.

I was going to ask Cliff from PureMVC about this. I am going to create a dummy project tonight with the exact same scenario, and post it if you like.
0
 
LVL 5

Expert Comment

by:Fuzzy_Logic_
Comment Utility
That would be really helpful.

FL
0
 

Author Comment

by:hallikpapa
Comment Utility
Here is a link to the project archive. I am printing all the objects the first time, but every other time you open the pop up window, the list is empty.

http://www.mediafire.com/?czyxntnmydg

Watch the trace logs, you see the cols field being populated.
0
 
LVL 5

Expert Comment

by:Fuzzy_Logic_
Comment Utility
Well I was nearly right.

You are not removing the mediator.

What is happening is first run:

PopUpMediator1 built (Name = "popUpMediator") PopUpWindow1 built List added by first Mediator with name "popUpManager" which references PopUpWindow1

PopUpManager removes PopUpWindow1 but PopUpMediator1 still has reference so it is not destroyed.

second run:

PopUpMediator2 built (Name = "popUpMediator" ) PopUpWindow2 built List added by the first Mediator with name "popUpManager" which is the first one that was built which references PopUpWindow1

PopUpManager removes PopUpWindow2 but PopUpMediator2 still has reference so it is not destroyed.

Essentially you end up with a load of PopUpMediators each one with its own PopUpWindow. But when pureMVC looks for the Mediator it will got to the first one in the list which has a reference to PopUpWindow1 and thats the one that always receives the column list. You only ever see that PopUpWindow on the first run.

 Think thats as clear as mud :-)

PopUpMediator.as
 

        public function PopUpMediator(viewComponent:PopUp):void

        {

            

            super(NAME, viewComponent);

            viewComponent.addEventListener(FlexEvent.CREATION_COMPLETE, popUpCreation_Complete);

            viewComponent.addEventListener(CloseEvent.CLOSE, popUp_Close);

             

            

        }
 

        private function popUp_Close(ce:CloseEvent):void

        {

            

           sendNotification(AppFacade.CLOSE_POPUP, viewComponent as PopUp);

            

        }
 
 

and in ClosePopUpWindowCommand.as
 

        override public function execute(notification:INotification):void

        {

           // Remove the mediator

            facade.removeMediator(PopUpMediator.NAME);

           

        }

 

Open in new window

0
 

Author Comment

by:hallikpapa
Comment Utility
That totally makes sense now that I can see that. THank you for taking the time and pointing it out. It will definetly help out in future projects!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now