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