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

Pages: [1]
Print
Author Topic: Doubt about views  (Read 12179 times)
Vander
Full Member
***
Posts: 32


View Profile Email
« on: May 07, 2008, 09:11:37 »

hello everyone...
im so excited starting my first app...
ive got some doubts..
my app have few "form views screens" plus few "windows"...
the windows thing, im sure that i must use popupwindow of a mxml titlewindow thing
okay, i can register it with a mediator, and popup it...
but... im in trouble with a thing: i want to have a general use one... that i can customize for example whats inside a text control, inside of a "generic" titlewindow, like for alert things with the possibility of some advanced behaviour than alertbox...
since its POPPED... i dunno how to access a control inside of it from the code where i instancied it (POPPEDUP IT) !!!! like a text control... (INSTEAD USING THE PARTICULAR TITLEWINDOW MEDIATOR... BECAUSE I WANT IT GENERIC... SO I CAN ACCESS DIRECTLY... IF AT LEAST I COULD ACCESS A FUNCTION ON THE TITLEWINDOW MEDIATOR, LIKE A GENERIC SETTER... BUT I DUNNO HOW TO ACCESS EVEN THE MEDIATOR OF THIS THING INSTANTIED, I MEAN POPPED heheh.... )

PLEASE HELP MEEEEEEEEEEEEE i must start this app soon.. because ive spent 3 months studying all this fascinating new world for me...

the second doubt, is the classical question about, views... viewstack... deferred instantiation, best practice, mediator, mediator registration, proxy for states, bla bla, whats the recommended approach on your point of view actually?

i think that many ppl can face this problem like me..
thanks everyone! :)
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: May 07, 2008, 10:15:41 »

Hi Vander,

Threads elsewhere in these forums lead to the following PureMVCPopUpManager, written by Paddy Keane. We'd talked of making it a utility, but never got around to it. Also his utility was in situ, written as part of the app, referring to the app's facade. I'm going to change the packaging here and the code to make it generic utility.

:
package org.puremvc.as3.utilities.flex.popup
{
   
    import flash.display.Sprite;
    import mx.core.Application;
    import mx.core.IFlexDisplayObject;
    import mx.managers.PopUpManager;
    import org.puremvc.as3.patterns.facade.Facade;
   
    public class PopUpManager
    {
               
        public static function openPopUp( ComponentClass:Class, MediatorClass:Class, modal:Boolean = false, center:Boolean = true):IFlexDisplayObject
        {
            var window:IFlexDisplayObject = PopUpManager.createPopUp( Application.application as Sprite, ComponentClass, modal );
            Facade.getInstance().registerMediator( new MediatorClass( window ) );
            if (center) PopUpManager.centerPopUp( window );
            return window;
        }
       
        public static function closePopUp( window:IFlexDisplayObject, mediatorName:String ):void
        {
            PopUpManager.removePopUp( window );
            Facade.getInstance().removeMediator( mediatorName );
            window = null;
        }

    }
}

Some Mediator listens for a 'Open Popup' event from its view component and then wants to popup an instance of, say, the HelpPopUp view component, mediated by a HelpPopUpMediator:

:
protected function openPopupHandler(e:Event):void
{
    PopUpManager.openPopUpWindow(HelpPopUp, HelpPopUpMediator);
}

Later, in the HelpPopUpMediator, it hears the 'Close PopUp' event and does:

:
protected function close(e:Event):void
{
    helpPopUp.removeEventListener("close", close);
    helpResource = null; // release any refs to complex objects
    PopUpManager.closePopUpWindow(helpPopUp, this.getMediatorName());
    delete this;
}

As for the viewstack/deferred instantiation issue, search these forums for 'deferred instantiation' you'll find a wealth of questions and answers on the topic. I'll have to round these up into a FAQ soon.

-=Cliff>
-=Cliff>
Logged
Vander
Full Member
***
Posts: 32


View Profile Email
« Reply #2 on: May 07, 2008, 01:33:21 »

thanks
i got it!!
var janela:TitleWindow=PopManager.openPopUp(Retry, RetryMediator);
janela.tests.text="ase";

worked but... i must changed the name, from popupmanager to popmanager, because popupmanager is already from flex, i dunno, he doesnt seems to liked even with another package...
i corrected too the name openpopupwindow to openpopup, i guess, you not perceived that ;)
and finally ive changed iflexdisplayobject, to titlewindow... on all places
obviously on my mediator, ive put a import of my retry titlewindow mxml

i also needed to cast as titlewindow
var window:TitleWindow = PopUpManager.createPopUp( Application.application as Sprite, ComponentClass, modal ) as TitleWindow;
on the popmanager code
:)
worked, now i can dynamically change the contents :)
im using it as a enhanced alertbox thing...
in this case.. dynamic, because im using a timer...
if a resultfault event... happens.. it try 3...2...1.. seconds.. :) and have a cancel button, to not try anymore :) sweet
a little offtopic.. ive also managed my proxy... to just one result and fault event :)
in the result ive used "if then" to compare what service was called :)

if(!service.operations.leusuarios==false)
{
    //setData( event.result );
    sendNotification( SERVICO_SUCESSO, event.result, "leusuarios" );
}
sweeeeeettt :)
so in the same result, i can parse which one :)
like something about your mediator handler approach :)
then on the mediator, ive just nested a switch with getType() :)
sweeet
on the fault event ive did the same...

NICE :)
thanks cliff...
Logged
neil
Jr. Member
**
Posts: 16


View Profile Email
« Reply #3 on: August 08, 2008, 04:54:08 »

How on earth do I pass arguments to a pop up?

I have a ClientList which has it's own Proxy and Mediator. When you click on an item, it opens a pop up with further details, called ClientForm. ClientForm also has it's own Proxy and Mediator.

ClientForm then should run a query to bring in data depending on the selected client.

How do I pass the selected client to the pop up.

I've seen the EmployeeAdmin demo and how it populates the form, but that is using the data already loaded in the ClientList.

I've also tried dynamically creating a textinput and then writing a vlaue to it, but I get errors as the textinput doesn't exist until the pop up is created.

Please help, it's driving me mad!!

Cheers,

Neil
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: August 08, 2008, 06:02:20 »

Once the custom TitleWindow is popped up its like any other component. It can expose properties that the mediator can set.

-=Cliff>
Logged
neil
Jr. Member
**
Posts: 16


View Profile Email
« Reply #5 on: August 08, 2008, 06:16:29 »

Hi Cliff. Thanks for the reply, but how do I pass the argument from the ClientList side of things to the ClientForm side of things. Where is the point where this would be passed?

I've looked at EmployeeAdmin, where the USER_SELECTED notification is sent to ApplicationFacade and then it appears that it's picked up by the RolePanelMediator, but when I try this, it doesn't seem to get passed through.

Is the notification like in EmployeeAdmin the right way to do this? (If I can get it working)?

Cheers,

Neil
Logged
neil
Jr. Member
**
Posts: 16


View Profile Email
« Reply #6 on: August 08, 2008, 06:26:07 »

Figured it out. I was setting the property on the ClientForm before it was actually opened.
Now it's passing the ID through.

Thanks for your help Cliff.

Neil
Logged
Pages: [1]
Print