2

I need to convert the following AngularJS application to a GWT application (though the question applies to any angular application). I would like to use the MVC pattern and UiBinder as suggested in the documentation but I'm unsure as to how the components of the angular application should correspond to the GWT one.

I've given it some thought already and here's my understanding - I'd be grateful if someone could say if I've got it right

  1. Each module should become a presenter
  2. One view per presenter
  3. Services must be initialised in the AppController and passed to the relevant presenters (similarly to how an eventBus is implemented in the MVC description)

Now I don't know how to put multiple presenters together, though, so that they create one page. Should I create a main view that would correspond to the AppController and then pass the relevant parts of that view to each presenter?

Also, what's the best way to handle modal dialogs? Should I just include them in the view, bind to the presenter and keep them hidden initially?

Bartek
  • 1,059
  • 6
  • 18

2 Answers2

1

I would recommend to use either Activities and Places or a fully fledged MVP framework like GWTP.

Regarding your questions:

  1. I think that's right
  2. One view per presenter is the usual approach. However you can also think of implementing different views for different devices (Desktop, Mobile, etc).
  3. I would recommend to use a dependency injection framework like GIN to inject services and components into your Presenters

It depends if you use Activities and Places or GWTP. GWTP has the conecept of PresenterWidget that can be nested in Presenters. For Activities and Places you can follow Thomas Broyer's recommendation.

In general I think Presenters and their corresponding Views should be standalone components that are usually associated with a Place. GWTP has the concept of Slots (i.e. side navigation, etc) where Presenters can reveal themselves.

Communication between Presenters should be done via the EventBus. GWTP has a concept of PopupPresenters but typically I think modal dialogs should be included in the View and handled by the parent Presenter (unless it contains a lot of business logic).

Ümit
  • 17,379
  • 7
  • 55
  • 74
0

You said:

Each module should become a presenter

look at [GWT Organize Projects][1]http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html It talks about modules in the section, "Modules: Units of Configuration" Basically, a module is just for configuration. You need a module for each entry point. People often have 1 module per page.

You said:

One view per presenter

This is usually the case.

You said:

Services must be initialized in the AppController and passed to the relevant presenters (similarly to how an eventBus is implemented in the MVC description)

Like Ümit said you should use Gin

Ümit recommended GWTP I'm no expert on GWTP but I used it briefly when I was a beginner and it was hard. I don't think it's good for beginners. Admittedly, it might be worth the investment of learning it. Like I said I'm no expert on GWTP.

jgleoj23
  • 262
  • 2
  • 9