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: trap/reacTo not working (fabrication 0.6)  (Read 11558 times)
smota
Newbie
*
Posts: 4


View Profile Email
« on: January 19, 2010, 04:38:36 »

Hi,

I'm implementing my first Fabrication app and I'm missing something since the trap/reactTo support is not working for any of my mediators.

I've double checked (following http://code.google.com/p/fabrication/wiki/Reactions):
1. My mediator extends FlexMediator;
2. I do have a property get function at the mediator for the component I'd like to reactTo/trap (btnEntrar);
3. My reactTo method is CamelCase named with the event (Click) CamelCased as well.

[EDITED] The only difference between the sample and my application that I'm aware of is the mediator registration:
:
registerMediator(new LoginScreenMediator(app.loginScreen));I'm not able to use correctly the resolve method receiving a cast exception when I do use it:
:
resolve(application).loginScreen (and I do have the loginScreen component at the application.

If I register the event listener (commented line on onRegister method) my application works fine.

Any idea on what am I missing?

:
package icm.main.view
{
import flash.events.MouseEvent;

import icm.main.*;
import icm.main.controller.*;
import icm.main.model.*;
import icm.main.model.vo.*;
import icm.main.view.screens.*;

import mx.controls.Button;

import org.puremvc.as3.multicore.interfaces.*;
import org.puremvc.as3.multicore.utilities.fabrication.patterns.mediator.FlexMediator;

    public class LoginScreenMediator extends FlexMediator
    {
        public static const NAME:String = "LoginScreenMediator";
       
private var configProxy:ConfigProxy;
private var localeProxy:LocaleProxy;
private var authProxy:AuthProxy;

public function LoginScreenMediator( viewComponent:LoginScreen )
        {
           super( NAME, viewComponent );
}

override public function onRegister():void {
        super.onRegister();
        //btnEntrar.addEventListener( MouseEvent.CLICK, trapBtnEntrarClick );
        }

protected function get loginScreen():LoginScreen
{
            return viewComponent as LoginScreen;
        }
       
        public function get btnEntrar():Button {
                return loginScreen.btnEntrar as Button;
        }
               
        public function respondToSuccessAuth(note:INotification):void {
        sendNotification( Messages.SHOW_MAIN_SCREEN );
        }
       
        public function respondToFailedAuth(note:INotification):void {
        loginScreen.userMessagePanel.visible = true;
var msgkey:String = note.getBody() as String;
var msgcomplement:String = note.getType() as String;
var msg:String = localeProxy.getText(msgkey);
if(msgcomplement != null)
msg += " " + msgcomplement;

loginScreen.userMessage.text =  msg;
        }

public function trapBtnEntrarClick(event:MouseEvent):void
{
var user:UserVO = new UserVO();
user.username = loginScreen.txtUsuario.text;
user.password = loginScreen.txtSenha.text;

return sendNotification(Messages.LOGIN, user);
}
    }
}
« Last Edit: January 19, 2010, 05:31:14 by smota » Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: January 19, 2010, 08:15:27 »

I'm pretty sure this project is dead. It should probably be removed from the forums. It's too bad, it had a lot of promise. I haven't seen Darshan in almost a year and his blog is silent too.
Logged
mariusht
Full Member
***
Posts: 26


View Profile Email
« Reply #2 on: January 19, 2010, 09:22:40 »

You should NOT access properties on component's children. This is a BAD PRACTICE.

LoginScreenMediator.as
var user:UserVO = new UserVO();
user.username = loginScreen.txtUsuario.text;
user.password = loginScreen.txtSenha.text;

create public properties that are considered the 'API' exposed to the mediator. Inside the view component, bind the text fields (or whatever subcomponents) data to these properties such that when an event is dispatched, the mediator inspects these API fields (not the text boxes).
by Cliff
http://forums.puremvc.org/index.php?topic=369.0

you would have something like this:
:
var user:UserVO = new UserVO();
user.username = loginScreen.username;
user.password = loginScreen.password;

Mariush T.
http://mariusht.com/blog/
Logged
smota
Newbie
*
Posts: 4


View Profile Email
« Reply #3 on: January 19, 2010, 02:37:03 »

I'm pretty sure this project is dead. It should probably be removed from the forums. It's too bad, it had a lot of promise. I haven't seen Darshan in almost a year and his blog is silent too.

Really? What a sad news!!!

It seems pretty stable and I've seen many new implementations using it.

From a newbie perspective I'd say that it's an amazing toolkit and my project is much better using it (considering coding style, logic, etc.).

Is there any technical reason to not use it?
(besides the lack of maintenance and considering projects that uses the supported features of PureMVC on Fabrication)

If the answer is no reason at all I'd say that the community can take over it  .... I'll digg a little bit into the source code ;)

Thanks

Samuel

EDITED: The code is being mantained: http://code.google.com/u/darshan.sawardekar/updates
No reason to worry ;)
« Last Edit: January 19, 2010, 02:48:40 by smota » Logged
smota
Newbie
*
Posts: 4


View Profile Email
« Reply #4 on: January 19, 2010, 03:09:13 »

You should NOT access properties on component's children. This is a BAD PRACTICE.

Great tip, thanks!
Logged
manuraj.dhanda
Jr. Member
**
Posts: 13


View Profile Email
« Reply #5 on: June 30, 2010, 12:26:00 »

I have the same situation where putting an addEventListener in onRegister works but reactTo does not work.

AppMediator's onRegister()
:
override public function onRegister():void {
super.onRegister();
registerMediator(new NavBarMediator(navBar));
}

In NavBarMediator,
:
public function get someButton():Button{
return navBar.someButton as Button;
}

public function reactToSomeButtonClick(e:MouseEvent):void {
trace("In NavBarMediator: responding to SomeButtonClick"); //never executed with 0.7
}
Logged
rafal.szemraj
Moderator
Full Member
*****
Posts: 41


View Profile WWW Email
« Reply #6 on: June 30, 2010, 02:45:04 »

Ok, please tell me - in onRegister in NavBarMediator this getter ( someButton ) returns good value ( reference ) or maybe null?
Logged
manuraj.dhanda
Jr. Member
**
Posts: 13


View Profile Email
« Reply #7 on: June 30, 2010, 10:28:02 »

someButton is NOT null in onRegister().

As soon as I do the following in onRegister(), it works.
:
someButton.addEventListener( MouseEvent.CLICK, trapSomeButtonClick );
Logged
rafal.szemraj
Moderator
Full Member
*****
Posts: 41


View Profile WWW Email
« Reply #8 on: July 01, 2010, 01:45:45 »

Can you send me your code example?
Logged
manuraj.dhanda
Jr. Member
**
Posts: 13


View Profile Email
« Reply #9 on: July 01, 2010, 03:22:40 »

I will try to put it in small example code and will post it back to you.
Logged
Pages: [1]
Print