Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought

Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / General Discussion / Notification received when child components aren't created yet on: October 24, 2008, 05:18:30
I have a view that extends VBox and contains a TabBar and a custom component.  The Mediator for this view (we'll call the view, FooView and FooViewMediator) receives a notification, which causes FooViewMediator to invoke FooView.update( items:ArrayCollection );

The 'update' method in FooView looks like:
  [Bindable] private var dpItems:ArrayCollection;

  public function update( items:ArrayCollection ) : void
      dpItems = items;
      var index:int = tabBar.selectedIndex;

       // do stuff with the index

<mx:TabBar id="tabBar" dataProvider="{dpItems}" />

The error I get is when I try and get the selectedIndex of the tabBar inside the 'update' method because 'tabBar' is still null.  I need the index to do something else in the view, however, the other custom component in the view is also still null.

I'm not sure how best to handle this.  I mean the FooView is not null which is how I was able to create the FooViewMediator. But now that the mediator is up it gets notifications, but it's child components in the FooView aren't ready. 

2  Announcements and General Discussion / General Discussion / Consumers Connected for a Long Time - Where to keep them? on: October 02, 2008, 03:01:58
So I have a Consumer which "subscribes" to a JMS topic.  Initially I had this thing in a Proxy so that it could get results and update its data, etc.

However, I felt like using Commands was a better approach.  The problem with a command is we must not use it to maintain state.  So, I shouldn't keep the "Consumer" object in it....b/c later I need to invoke "Consumer.unsubscribe" to clean up my connection.

Any suggestions on this?
3  Announcements and General Discussion / General Discussion / Best Approach for Managing User Navigation on: September 26, 2008, 03:07:04
My Flex application has two navigation controls that are always visible to the user.  At the top there is a bread crumb (http://blog.smashedapples.com/2008/06/flex-breadcrumb.html) and on the left side is an Accordion (similar to something in Microsoft Outlook, etc). 

Sample menu options might include:

The BreadCrumb navigator uses the menus defined above, the accordion is exactly the same except it does not have a "home".  So in the Accordion there are two "header" buttons (not sure what the top level button is that you click on), one says "File" and the other says "Options".  When the "File" accordion option is selected the user can see three "LinkButton" controls, one each for "New", "Save" and "Close".  Same goes for "Options" accordion button.

These two navigation controls are defined in my AppMain.mxml (the root Application).  Basically I need to keep track of where the user is in the view so that at some point a previously viewed view can be shown.  For example, image if the user goes to Preferences.  If they start changing values and then decide they don't want to do that, they can click a "cancel" button (on the Preferences screen) and the application should go back to showing whatever view they were in previously.

I should mention that the content area that takes up the majority of the display (to the right of the Accordion) is implemented as a ViewStack, so for example when you click on "Preferences" it's view is shown.
Any suggestions on the best way to do this?

I was going to have the navigation controls (BreadCrumb and Accordion) fire events from AppMain.mxml and let my ApplicationMediator.as handle them by saying "appMainView.viewStack.selectedIndex = 2" (something like that).  I was thinking about keeping some sort of view state in the proxy so when another view says "show previous view" (i.e. the user clicked cancel) the mediator can access the proxy find out what the previous view was and show it.

Just curious, what your thoughts are, have you done this, any tips???
4  Announcements and General Discussion / General Discussion / Best way to take single view to multiple views on: September 24, 2008, 06:36:43
I currently have a rather complex UI.  In it there is a particular view which has its own Proxy, Mediator and view components, but now I need to allow the user to multiple displays of it.  So instead of a single view, maybe I use a tabbed style view.

For example, say this view displays stats about ONE baseball team.  It lists players, batting averages, win/loss, etc.  If they want to look at another team there is a combo box and they select a team and click "update" and the view updates.

Now, I need to have N-number of these views displayed for different teams.  So, if I did a tabbed view they could have 3 tabs (for example), each tab displays stats for a different team.

Is there a recommended approach to refactoring my code to support this?  Right now it's all based on getting data and displaying data for one team.  Now it seems like I need a parent proxy (which handles giving data about a team to the correct child proxy) and a parent mediator and a parent view.

What do you think?
5  Announcements and General Discussion / General Discussion / Chain Commands that Don't Execute Until Previous Command Does on: September 09, 2008, 08:38:55
I have a MacroCommand and it executes Command A, B, then C.  Currently B needs some data that A gets to do it's function.  However, A calls a remote object asynchronously so it's 'execute' method finishes quickly and the MacroCommand calls B.execute. 

Should I implement something that causes MacroCommand to wait for A to "finish" before calling B?  or Should I create a special Proxy that stores the temporary results for me?

6  Announcements and General Discussion / General Discussion / Removing Unused Mediators - should it be done when using ViewStack? on: August 07, 2008, 05:12:03
So there is a blog post about the "10 tips for working with PureMVC" (http://www.websector.de/blog/2007/12/25/10-tips-for-working-with-puremvc/).

Number 8 says:

In some cases you don’t use a Mediator and its View Components anymore. Then remove the Mediator using facade.removeMediator(MyMediator.NAME); in conjunction with a self created destroy() method to remove the ViewComponent including all listeners, timer, references, etc. for a successful garbage collection.

So with a ViewStack, when the user is no longer looking at a view is it best to remove the mediator, listeners, etc for the view that is no longer being displayed (b/c the user chose to view a different element of the ViewStack?
7  Announcements and General Discussion / General Discussion / Best Practice for storing currently selected item? on: August 06, 2008, 09:15:32
I have a list and when I select an item I want to update a form.  So say the list has Person objects and when you select one a Form (in the same View) has a Name and Age field that get populated with the selected object.

Is it best to keep a, "private var selected:PersonVO" in the view or should I keep "selected" in the proxy?  If I keep it in the proxy, I'd have to have my view catch the "list change" event, fire off an event, the mediator would catch it and do "proxy.selected = view.list.selectedItem".  Then the proxy would maybe send out a notification, the mediator would catch the notification and populate the form.

Would the notification be defined in the ApplicationFacade?  (i.e. public static const PERSON_SELECTED:String ="personSelected");

Also, if it did go the route of sending an event and so on, I would need a "PersonSelectedCommand" right?  Since the mediator shouldn't talk directly to the proxy, it should use a notification.

Is one "better" than the other?
8  Announcements and General Discussion / General Discussion / View component is null during startup? on: August 05, 2008, 11:55:05
I have the following setup:

StartupCommand creates ApplicationMediator
ApplicationMediator creates FooMediator (and passes it view.FooView)

The FooMediator constructor looks like:
public function FooMediator(viewComponent:Object=null) {
      super(NAME, viewComponent);

private function get view():FooView {
   return viewComponent as FooView;

I get the following on the "view.dummButton.addEventListener" line:
Cannot access a property or method of a null object reference.

In the debugger I see that "dummyButton" is null.

The FooView looks like:
<mx:Panel ....>
<mx:Button id="dummyButton" label="Close" />

Any ideas?
9  Announcements and General Discussion / General Discussion / FlexBuilder3 Error - 1017: The definition of base class Facade was not found. on: August 01, 2008, 04:12:21
I have a Flex project in FlexBuilder3 which also has a pom.xml.  I have added the following to my pom.xml:

However, FlexBuilder gives me two errors:
1017: The definition of base class Facade was not found.
1020: Method marked override must override another method.

The lines of code that those two errors reference to, respectively, are:
public class ApplicationFacade extends Facade
override protected function initializeController():void {

Do I need to add PureMVC to my "Flex Build Path" (i.e. under the "Properties" for my Flex project)?  If so, I thought by having Maven include the dependency I didn't need to do that.

Pages: [1]