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: Printing in a PureMVC app...  (Read 5547 times)
lomotion1
Newbie
*
Posts: 1


View Profile Email
« on: August 25, 2009, 11:04:12 »

I am working on an application using PureMVC for the first time.  I have the need to print some visual data.  I have a mediator, lets call it PrintAreaMediator, that is listening for the PRINT notification which is sent from another mediator which stewards a file menu (including the print button).  Should the PrintAreaMediator kick off the printjob (passing its viewComponent as the print content) or should a command (PrintCommand) be used instead in which it would retrieve the PrintAreaMediator and ask for its' viewComponent to pass to the printjob?  Also, where would be the best place (package wise) to place the Printer class (it is a singleton that wraps a printjob).  Do many of you create a utils package as well alongside the model, view, controller?
Logged
sasuke
Full Member
***
Posts: 29


View Profile Email
« Reply #1 on: August 27, 2009, 12:42:19 »

I am working on an application using PureMVC for the first time.  I have the need to print some visual data.  I have a mediator, lets call it PrintAreaMediator, that is listening for the PRINT notification which is sent from another mediator which stewards a file menu (including the print button).  Should the PrintAreaMediator kick off the printjob (passing its viewComponent as the print content) or should a command (PrintCommand) be used instead in which it would retrieve the PrintAreaMediator and ask for its' viewComponent to pass to the printjob?  Also, where would be the best place (package wise) to place the Printer class (it is a singleton that wraps a printjob).  Do many of you create a utils package as well alongside the model, view, controller?
Hi there,

I think I can come up with two ways to tackle this issue:
- You should have a parent mediator which would be listening to such 'cross-cutting concerns' and sending appropriate notifications in response i.e. since you have two view areas in your application, you would also have some sort of mediation logic or a mediator for the entire application and that mediator automagially becomes your parent mediator in this case.
- Send a notification to the facade from your Menumediator which would be turn be broadcasted to all the puremvc actors i.e. facade.sendNotification(SOME_THING). Make the PrintAreaMediator listen to this notification and your job is done. Make sure you create a command for this printing since there might be other areas in your application which might be needing the print facility.

And yes, I do end up creating util packages for things which have no bearing whatsoever on the MVC way of things. Though creating or using a Proxy pattern to handle this printing job would be a good PureMVC exercise.... :-)
Logged
Pages: [1]
Print