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: Nested Mediator Typing  (Read 3672 times)
dbasch
Jr. Member
**
Posts: 17


View Profile Email
« on: January 14, 2009, 12:01:15 »

Hello all,

I am trying to figure out the best way to handle the grouping of mediators. For example, let's assume that we have a library with books, book chapters and book pages.

BookMediator_AtlasShrugged
ChapterMediator_1
ChapterMediator_2
PageMediator_1
PageMediator_2
BookMediator_AnarchistsCookbook
ChapterMediator_1
ChapterMediator_2
PageMediator_1
PageMediator_2

It seems that the only way to ensure that notifications are sent to the proper PageMediator is to have a naming schema established. Something like this:

"BookMediator_AtlasShrugged_ChapterMediator_1_PageMediator_1"

However, this requires that the name of any "parent" mediators be available to PageMediator when it is instantiated. I must be missing something here.

As an example, let's step through an "Add Page" command followed by a "Set Page Font" command with some psuedocode.

:

PageVO:
text:String = "It was the worst of times, it was the..."
FontVO:
font:String = "WingDing"

---------------------------------------

BookProxy.addPage(pageVO):
facade.sendNotification(ApplicationFacade.ADD_PAGE_CMD, pageVO)

AddPageCommand:
// HOW DO WE DETERMINE THE NAME TO GIVE TO THE MEDIATOR HERE?
facade.registerMediator(new PageMediator("BookMediator_AtlasShrugged_ChapterMediator_1_PageMediator_3"));

// HOW DO WE DETERMINE WHICH BOOK AND CHAPTER TO ADD THE PAGE TO HERE?
facade.sendNotification(ApplicationFacade.ADD_PAGE_VC, pageVO, "BookMediator_AtlasShrugged_ChapterMediator_1_PageMediator_3")

---------------------------------------

PageMediator.setPageFont(fontVO):
facade.sendNotification(ApplicationFacade.SET_PAGE_FONT_CMD, fontVO,  this.getMedatorName())

SetPageFontCommand:
// HOW DO WE DETERMINE WHICH PAGE TO SET THE FONT OF HERE?
facade.sendNotification(ApplicationFacade.SET_PAGE_VC_FONT, fontVO,  "BookMediator_AtlasShrugged_ChapterMediator_1_PageMediator_3")

---------------------------------------

What techniques is everyone using to deal with this sort of issue? Should I add the grouping information to the Value Objects? Should I be trying to retrieve the grouping info from a Proxy?

Thanks,
Derek Basch

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



View Profile WWW Email
« Reply #1 on: January 16, 2009, 07:18:23 »

In this situation, you'd want to derive the mediator names from the unique fields of the VOs you are working with. If mediators are created for every page you touch, then:

:
facade.registerMediator(new PageMediator("Library_"+
PageVO.bookId+"-"+ PageVO.pageNum+"_"++"mediator");
[\code]

You might want a a getter method on the VOs that create the name since they have all the props and are used across all three tiers.

-=Cliff>
Logged
dbasch
Jr. Member
**
Posts: 17


View Profile Email
« Reply #2 on: January 16, 2009, 09:56:55 »

In this situation, you'd want to derive the mediator names from the unique fields of the VOs you are working with.

Thanks Cliff,

I am happy that I was on the right track.

I think I am going to end up with some ridiculously long winded mediator names  ;D

Cheers,
Derek
Logged
Pages: [1]
Print