tags:

views:

308

answers:

1

Hello!

Think there might be something about this MVP approach I have completely misunderstood.

Currently I am struggling to apply the MVP pattern to the part of my application consisting of a StackLayoutPanel (accordion). To me it seems natural to have a presenter and a view per stack... but how do I allow the different presenters to react when the user switch the state of the stack panel?

If someone could sketch an application of the MVP pattern in the case of an accordion application I would be really, really grateful! This is really getting on my nerves! ;D

Thanks a lot from Stine :)

A: 

Event bus might be way for you to pass the information between presenters - just be careful not to dump every possible event in the bus.

http://code.google.com/events/io/2009/sessions/GoogleWebToolkitBestPractices.html

Petteri Hietavirta
Yes, makes sense, but unfortunately I am not at that point yet ;) I am at the point where I have to build up the stack panel... and the different sections should not be initialized before they actually become visible! Hmm... maybe I am talking rubbish here :( *Sigh*
Stine
Event bus is the glue that holds this all together - IMHO you should understand that concept without proceeding further. Watch Ray Ryan's presentation many times, search for more tutorials on GWT + MVP (on SO or on GWT's Google Group). And maybe start with something smaller/easier to grasp.
Igor Klimer
I must admit that I have actually been listening to Ray Ryan several times.. and I do think that I understand the simple examples.. but the minute the application gets more hierarchic my brain starts smoking!! And I have not been able to find any good examples of how to structure that kind of applications out there! Well, I will do as you suggest.. again ;) And then try to keep the event bus very much in mind! :) Thank you for your input!
Stine
There's a more comprehensive example at http://code.google.com/p/gwt-mvp-sample/ and http://blog.hivedevelopment.co.uk/2009/08/google-web-toolkit-gwt-mvp-example.html There are "frameworks" like gwt-mvp, but IMHO they are overly complicated and it is best to just roll out one yourself - you'll get what you want and you'll understand the process better. PS: I know MVP can be frustrating at times, but believe me - when a GWT project gets large and it doesn't follow MVP or something similar it gets even more frustrating ;)
Igor Klimer
I have the exact same feeling about those "frameworks".. and do not feel like using them without at least first understanding exactly what the main process is all about.. just did not know if it was me being stupid - but now that we are two of the same opinion (if I understand you right) I guess I can stick to it 8D And am also pretty convinced about the danger of not applying a design pattern!! About the Event bus.. it is okay to add events to it inside a view class? :) And thanks a lot for commenting!!
Stine