|
|
Show Posts
|
Pages: 1 2 [3] 4
|
31
|
Announcements and General Discussion / Getting Started / Re: ViewStack: Change view but dont load view components
|
on: August 18, 2008, 05:35:01
|
I tried now a different approach debugging the app to see what is happens and i see this:
- It changes the view and register the mediator just like the ApplicationMediator i posted. - Now i add a creationComplete in Main.mxml on the view "userManagerPanel" - And when it's debbug first change view and register mediator, but it does't create complete the View so because of this i got the null reference
So what is the best way to register the mediator? it's a best practice put a creationComplete in the view to send a notification to register the mediator? Because the problem i am getting is that it register the Mediador but the View isn't totally build so when i register the mediator the view are loading and don't instanciate the userList.
I have to thank you cliff by all the support and assistance you have given, thank you.
Daniel Gomes
|
|
|
32
|
Announcements and General Discussion / Getting Started / Re: ViewStack: Change view but dont load view components
|
on: August 18, 2008, 05:01:09
|
Hi Cliff,
no i am doing it just the way you post in the newer FAQ entry, i will post to you the ApplicationMediator.
package com.pt.onedesign.user_manager.view { import com.pt.onedesign.user_manager.model.LoginProxy; import com.pt.onedesign.user_manager.model.UserProxy; import mx.controls.Alert; import mx.core.Container; import org.puremvc.as3.interfaces.IMediator; import org.puremvc.as3.interfaces.INotification; import org.puremvc.as3.patterns.mediator.Mediator; public class ApplicationMediator extends Mediator implements IMediator { //Define Proxy private var _loginProxy : LoginProxy; private var _userProxy : UserProxy; //Define static const for mediator public static const NAME:String = "ApplicationMediator"; // Define const names for change ViewStack views. public static const LOGIN_PANEL : int = 0; public static const USER_MANAGER_PANEL : int = 1; public function ApplicationMediator( viewComponent: Main ):void { super ( NAME, viewComponent );
// local reference to the LoginProxy _loginProxy = facade.retrieveProxy(LoginProxy.NAME) as LoginProxy; facade.registerMediator(new LoginPanelMediator(app.loginPanel)); //facade.registerMediator(new UserListMediator(app.userManagerPanel.userList)); } override public function listNotificationInterests():Array { return [ LoginProxy.LOGIN_SUCCESS, LoginProxy.LOGIN_FAILED ] } override public function handleNotification( note:INotification ):void { switch ( note.getName() ) { case LoginProxy.LOGIN_FAILED: Alert.show("Invalid username or password, please try it again.","Login Failed"); app.currentViewSelector = LOGIN_PANEL; break; case LoginProxy.LOGIN_SUCCESS: app.currentViewSelector = USER_MANAGER_PANEL; facade.registerMediator(new UserListMediator(app.activeView.userList)); facade.sendNotification(UserProxy.GET_USERS_LIST); break; } } protected function get app(): Main { return viewComponent as Main; } } } i have and id for userManagerPanel,userList and userForm but i didn't give them a "name" property. I am getting the view this form:
Main.mxml
[Bindable] public var currentViewSelector:int = ApplicationMediator.LOGIN_PANEL; public var activeView:Object; ]]> </mx:Script> <mx:Binding source="appView.selectedChild" destination="activeView" /> <mx:ViewStack id="appView" resizeToContent="true" selectedIndex="{currentViewSelector}" > <loginComp:LoginPanel id="loginPanel"/> <userManagerComp:UserManager id="userManagerPanel"/> </mx:ViewStack> The unique difference between my code and yours of the FAQ post is that i dont have a button and i change the view and add the mediator when a LOGIN_SUCCESS notification is send, and my public var currentViewSelector:int and yours is String (but if i change to string give me an error).
Daniel Gomes
|
|
|
33
|
PureMVC Manifold / MultiCore Version / Easy Pipes Demo?
|
on: August 18, 2008, 04:53:52
|
Hi Guys,
I have been testing the Demo Pipes and I am with many difficulties to understand, then I would like to ask if someone could develop a simpler or more easy to understand demo? (something "basic")
Thanks,
Daniel Gomes
|
|
|
34
|
Announcements and General Discussion / Getting Started / Re: ViewStack: Change view but dont load view components
|
on: August 18, 2008, 01:44:07
|
Well, i tried, tried, tried and nothing only still give me null reference so my question is i need to have a mediator to UserManagerPanel to instance is components? I am really stuck on it and i dont understand why it dont instantied it and give me null reference i implemented you solution but the child of UserManager like UserList and UserForm still give me null i debug from a lot of different ways and still see the null And the stupid thing is, it puts the components in the view but dont give them an instance Daniel Gomes
|
|
|
37
|
Announcements and General Discussion / Getting Started / Re: ViewStack: Change view but dont load view components
|
on: August 16, 2008, 05:21:37
|
I was trying implement it but getting null again :s
will post the code:
Main.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" xmlns:loginComp="com.pt.onedesign.user_manager.view.components.Login.*" xmlns:userManagerComp="com.pt.onedesign.user_manager.view.components.UserManager.*" initialize="facade.startupApp(this)">
<mx:Script> <![CDATA[ import com.pt.onedesign.user_manager.view.ApplicationMediator; import com.pt.onedesign.user_manager.ApplicationFacade; private var facade:ApplicationFacade = ApplicationFacade.getInstance();
[Bindable] public var currentViewSelector:uint = ApplicationMediator.LOGIN_PANEL; public var activeView:Object; ]]> </mx:Script> <mx:Binding source="appView.selectedChild" destination="activeView"/> <mx:ViewStack id="appView" resizeToContent="true" selectedIndex="{currentViewSelector}"> <loginComp:LoginPanel id="loginPanel" /> <userManagerComp:UserManager id="userManagerPanel"/> </mx:ViewStack> </mx:Application> ApplicationMediator.as
package com.pt.onedesign.user_manager.view { import com.pt.onedesign.user_manager.model.LoginProxy; import com.pt.onedesign.user_manager.model.UserProxy; import mx.controls.Alert; import mx.core.Container; import org.puremvc.as3.interfaces.IMediator; import org.puremvc.as3.interfaces.INotification; import org.puremvc.as3.patterns.mediator.Mediator; public class ApplicationMediator extends Mediator implements IMediator { //Define Proxy private var _loginProxy : LoginProxy; private var _userProxy : UserProxy; //Define static const for mediator public static const NAME:String = "ApplicationMediator"; // Define const names for change ViewStack views. public static const LOGIN_PANEL : Number = 0; public static const USER_MANAGER_PANEL : Number = 1; public function ApplicationMediator( viewComponent: Main ):void { super ( NAME, viewComponent );
// local reference to the LoginProxy _loginProxy = facade.retrieveProxy(LoginProxy.NAME) as LoginProxy; facade.registerMediator(new LoginPanelMediator(app.loginPanel)); //facade.registerMediator(new UserListMediator(app.userManagerPanel.userList)); } protected function get app(): Main { return viewComponent as Main; } override public function listNotificationInterests():Array { return [ LoginProxy.LOGIN_SUCCESS, LoginProxy.LOGIN_FAILED ] } override public function handleNotification( note:INotification ):void { var child:Container; switch ( note.getName() ) { case LoginProxy.LOGIN_FAILED: Alert.show("Invalid username or password, please try it again.","Login Failed"); app.currentViewSelector = LOGIN_PANEL; break; case LoginProxy.LOGIN_SUCCESS: app.currentViewSelector = USER_MANAGER_PANEL; facade.registerMediator(new UserListMediator(app.activeView.userList)); break; } }
} } UserManager.mxml (Component that receive more 2 components)
<?xml version="1.0" encoding="utf-8"?> <mx:Canvas width="900" xmlns:comps="com.pt.onedesign.user_manager.view.components.UserManager.components.*" xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:HBox horizontalGap="10" horizontalAlign="center" verticalAlign="top" width="100%" paddingTop="15"> <mx:VBox verticalGap="10"> <comps:UserList id="userList"/> </mx:VBox> <comps:UserForm id="userForm"/> </mx:HBox>
</mx:Canvas>
It's strange, but the same thing in ApplicationMediator.as if i put the this:
case LoginProxy.LOGIN_SUCCESS: app.currentViewSelector = USER_MANAGER_PANEL; app.activeView.creationPolicy=all; <------------ It make the other components avaible but without this they still null :| facade.registerMediator(new UserListMediator(app.activeView.userList)); break; I really don't understand why it don't load the components :|
|
|
|
40
|
Announcements and General Discussion / Getting Started / ViewStack: Change view but dont load view components
|
on: August 16, 2008, 12:28:25
|
Hi guys,
I am having some difficulties loading views components in viewstack. See the steps:
- MainApp load - ViewStack default view: A - I loggin - ViewStack Changes view to: B - View B have more two components inside (B.1,B.2) - When i tried send data for components B.1 and B.2 their are unavaible it sends an error that object is null
So i have doing some search and find maybe it's creationPolicy, the default is auto and i changed for all and the objects are now avaliable.
But my question/difficulty is load the components without the creationPolicy all, becaus now my App just have 2 views and 3 components, but when i have 50 components load all at same time dont make sense and make the server slow and the application, or am i wrong? What is the best practice to do this?
Thanks,
Daniel Gomes
|
|
|
41
|
PureMVC Manifold / MultiCore Version / Re: Notification Question/Best Practices
|
on: August 16, 2008, 05:12:12
|
Hi Cliff, thanks for reply. I was trying modularity first, until i faced this problem i will see the pipeworks demo and is code and try to understand it. For now exists any topic or article explaning the difference between pipes and modularity? Thanks, Daniel Gomes
|
|
|
42
|
PureMVC Manifold / MultiCore Version / The difference between the Modularity and PipeWorks Demos
|
on: August 16, 2008, 04:37:11
|
Hi guys,
I am starting now with AS3 Multicore, and i'm facing a problem. I have a flex library that for now contain a Login Module that is attach to my project. When i loggedin in LoginPanel it sends a notification and my question is what is the best away/practice to make it reusable and without Login Module have to know the main project?
I thought maybe Login Module sending a notification that main project can hear and handle but i don't know if it's possible and if it is who to do it.
Thanks,
Daniel Gomes
|
|
|
43
|
PureMVC Manifold / Standard Version / Re: Having difficulties changing views
|
on: August 13, 2008, 04:01:04
|
Have good news, for now it removes the Login Panel and add the Main App Painel (i changed some names and organized better the components). But i still have some problems, because i only can remove the Login Panel with "app.removeChildAt(0)" if i tried with "app.removeChild(loginPanel)" it give a error :S and to add the Main App Painel i have to create a var and create a new MainApp. (see below in code) This is my ApplicationMediator.as //Define Proxy private var _loginProxy : LoginProxy; private var _userProxy : UserProxy; //Define static const for mediator public static const NAME:String = "ApplicationMediator"; public function ApplicationMediator( viewComponent: Login ):void { super ( NAME, viewComponent );
// local reference to the LoginProxy _loginProxy = facade.retrieveProxy(LoginProxy.NAME) as LoginProxy; _userProxy = facade.retrieveProxy(UserProxy.NAME) as UserProxy; facade.registerMediator(new LoginPanelMediator(app.loginPanel)); } override public function listNotificationInterests():Array { return [ ApplicationFacade.LOGIN_SUCCESS, ApplicationFacade.LOGIN_FAILED, ] } override public function handleNotification( note:INotification ):void { switch ( note.getName() ) { case ApplicationFacade.LOGIN_FAILED: break; case ApplicationFacade.LOGIN_SUCCESS: app.appView.removeChildAt(0); var mainAppPanel: MainApp = new MainApp(); app.addChild(mainAppPanel); break; } } private function get app(): Login { return viewComponent as Login; } // assuming the login panel is there first and has id loginPanel. private function get loginPanel(): Login { return app.loginPanel as Login; } My MainAppCommand.as /** * Listens to the login notification retrieving the LoginProxy and does login */ override public function execute(note:INotification):void { var userVO:UserVO = note.getBody() as UserVO; var mainApp:MainApp = new MainApp(); mainApp.id = 'mainAppPanel'; sendNotification( ApplicationFacade.LOGIN_SUCCESS ); sendNotification( ApplicationFacade.ADD_MAIN_APP ); } My ApplicationFacade.as //Notifications const names public static const STARTUP_APP:String = "startupApp"; //Login const names public static const LOGIN:String = "login"; public static const LOGIN_SUCCESS:String = "loginSuccess"; public static const LOGIN_FAILED:String = "loginFailed"; //Main const names public static const MAIN_APP:String = "mainApp"; public static const ADD_MAIN_APP:String = "addMainApp"; /** * Singleton ApplicationFacade Factory Method */ public static function getInstance() : ApplicationFacade { if( instance == null) instance = new ApplicationFacade(); return instance as ApplicationFacade; } /** * Start the application */ public function startupApp(app:Login):void { sendNotification(STARTUP_APP, app); } /** * Register Commands with the Controller */ override protected function initializeController( ) : void { super.initializeController(); registerCommand( STARTUP_APP, StartupAppCommand ); registerCommand( LOGIN, LoginCommand ); } And this is my new File Structure: Something is missing me, just dont know where :S UPDATE: I just upload the App you can see it here: http://onedesign.com.pt/puremvc/Login.html Username: admin Password: admin Thanks for your time, Daniel Gomes
|
|
|
45
|
PureMVC Manifold / Standard Version / Re: Having difficulties changing views
|
on: August 13, 2008, 08:50:53
|
Hi Cliff,
Yes you are assuming right, i have a ViewStack with LoginPanel and UserManagementContainer as a child and the objectivo is switch between them.
Now i understand a little more the "concept" of ApplicationMediator, but i have another question maybe a stupid one, so and if i dont have a ViewStack in main app, how the ApplicationMediator remove/add views from main app?
Thanks for your reply and explanation,
Daniel Gomes
|
|
|
|
|