StackLayoutPanel and MVP

Think, maybe, something about this MVP approach I did not completely understand.

I am currently struggling to apply the MVP pattern to part of my application consisting of a StackLayoutPanel (accordion). For me, of course, there is a presenter and presentation for each stack ... but how can I let other presenters respond when the user switches the state of the stack panel?

If someone could sketch out an MVP template application in case of an accordion application, I would really, really appreciate it! This is really nervous !; D

+4
source share
2 answers

An event bus can be a way of transferring information between hosts - just be careful not to reset all possible events on the bus.

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

0
source

The MVP-related classes provided by GWT have a restriction that the underlying state of the application is associated with places. Actions start and stop, and views are displayed depending on where you are located and which are associated with browser IDs / URL fragment identifiers.

With the stack panel, you are likely to switch between widgets on the stack without changing the place. However, it often makes sense to have separate actions and views for each widget in the panel.

The solution is to create a common activity and a general view for controlling the stack panel, and then actions and views for each widget in the stack panel. Your common activity is a normal GWT activity, but it acts as a small activity manager for the built-in actions of the stack panel. General activity will receive (via the event bus and general view) events on the activation or deactivation of widgets on the stack panel, if necessary, it starts and stops built-in actions.

There is a similar problem in the tab bar. You can check how I did this for the tab bar by doing a quick git clone http://lais.mora.edu.mx/gitrepo/pescador.git and checking java/webclient/src/main/java/mx/org/pescador/client/content/BodyContentActivityImpl.java and related code.

0
source

Source: https://habr.com/ru/post/1302114/


All Articles