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: How to pass data from different view and pass it to command class  (Read 8667 times)
akmansoor
Newbie
*
Posts: 9


View Profile Email
« on: December 18, 2008, 01:13:44 »

Hi,

I have three views when I click on a button in one view, it need to pass data from other two views. What is the best way do this. Is there any viewlocater to look for other view datas.

all the views are having its own mediator doing its own thing.



Thanks,
Mansoor Achire
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: December 18, 2008, 01:18:01 »

Then have the mediator for the view with the button send a notification that the other two mediators are interested in. Upon notification, those mediators should that the data exposed to them by their views and send their own notifications carrying the data to be handled by the commands in question.

-=Cliff>
Logged
akmansoor
Newbie
*
Posts: 9


View Profile Email
« Reply #2 on: December 18, 2008, 01:27:45 »

Thanks Cliff, Is this the only way?. I was looking for a kind of viewlocatar
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: December 18, 2008, 01:40:21 »

In the scenario I described, you'd have to have 2 commands responding which might not be what you want if you're needing to combine that data somehow in the command.

So, if you want to implement a scheme like the view locator pattern, then simply add methods to your mediators to return the data from their views.

Have the mediator for the button-containing view send a note that triggers a command that retrieves the other 2 mediators, gets the data by calling their methods (not by grabbing and being intimate with their actual view components), and then does whatever it needs to with it.
Note that this builds a coupling between the command and the mediators since the command must know the names of the mediators to retrieve, so it should be done if you can avoid it, but that's why retrieveMediator is there.

-=Cliff>
Logged
akmansoor
Newbie
*
Posts: 9


View Profile Email
« Reply #4 on: December 18, 2008, 02:16:41 »

Is it the below approach good.

All the three views will be inside a main view
The Main View Mediator will listen the button click (make event bubbles true)
then the main view will get the data using mainview.chilview.data


Regards,
Mansoor Achire
Logged
Pages: [1]
Print