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: Doub about sending that from view to mediator  (Read 10328 times)
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« on: October 14, 2008, 10:11:06 »

Hi,

I'm trying to follow the good development guidelines of the pure mvc.

For that i'm making events in my buttons and then handle them in the mediator side.

The problem is that i need to send a parameter as well... How can i do that?

This is what i have:

// view side

public static const DELETE_USER:String = 'deleteUser';

<mx:Button label="Delete" click="sendEvent(DELETE_USER)" />

// mediator side

private function onDeleteUser():void
{
// i need to get the user id parameter
sendNotification( ApplicationFacade.USER_DELETE, usersList.selectedItem.@id );            
}

How can i do this?

Thanks

Nuno

Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: October 14, 2008, 12:49:23 »

I'm not sure I understand the question. What you have should work fine, passing the ItemId in the body of the notification, then the command using the body of the message and does it's thing.

If you mean how do you send the ID in the event, the simple answer is to create a custom event that has a variable containing the value.
Logged
sinosoidal
Jr. Member
**
Posts: 15


View Profile Email
« Reply #2 on: October 15, 2008, 01:49:16 »

Hi,

Thanks for your reply.

What about sending the notification right from the event in the view?

Does this breaks the model a lot?

Thanks,

Nuno
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #3 on: October 15, 2008, 06:06:57 »

Thanks for your reply.

What about sending the notification right from the event in the view?

Does this breaks the model a lot?

You shouldn't have PMVC code in your view components themselves, as this will bind your components to the particular app (by using the ApplicationFacade.NOTE_NAME). Best to have your mediator listen for the event, then have it dispatch the notification from there. This keeps your components oblivious to how those events are being used and thus making them reusable in other apps.
Logged
Pages: [1]
Print