>From what I've read and done with MVP, you would generally implement
your View as two separate classes (HeaderView and HeaderPresenter).
Were that the case, your App.ui.xml wouldn't contain the actual views,
but rather placeholder slots for the children that the Presenter would
get from the child Presenters (HeaderPresenter, which has a
HeaderView, and ContentPresenter, which has a ContentView). You would
inject the HeaderPresenter and ContentPresenter into your
AppPresenter, which could then get and insert the child Views into
it's own slots.
It looks like, though, you're combining the Presenter and View roles
for your App, Header, and Content classes. That's not necessarily a
bad thing, but it means that your unit tests (you are unit testing,
right?) won't work in plain old JUnit... they'll have to use the
(slower) GWTTestCase harness, since they explicitly depend on
UiBinder, which won't work outside of a "development" mode.
Nonetheless, since you have combined them, I'll assume you are at
least using an MVP framework to help you? If you are using an MVP
framework like gwt-presenter or gwt-mvp, then the Presenter classes
have a bind() method (or something similar).
When one Presenter "contains" other presenters, as is the case here
for your AppController, then when it binds, it should take
responsibility for binding it's contained presenters at the right
time.
You'll need to use UiBinder to get references to your "child"
presenters. For the sake of this post, I will assume that, like
AppController below, your Header and Content classes also implement
both Presenter and View interfaces.
<g:DockLayoutPanel unit='PX'>
<g:north size='121'>
<my:Header ui:field="header" /> <!-- NB: ui:field -->
</g:north>
<g:center size="200">
<g:ScrollPanel>
<my:Content ui:field="content" /> <!-- NB: ui:field -->
</g:ScrollPanel>
</g:center>
</g:DockLayoutPanel>
In AppController, you'll have something like:
public class AppController implements Presenter, View {
interface Binder extends UiBinder<DockLayoutPanel, AppController> {}
private static Binder binder = GWT.create(Binder.class);
@UiField
Header header; // will be populated by UiBinder with your Header
// alternatively, you could set @UiField(provided=true) and use DI
// to get the instance of Header; pass it in as a constructor
arg ;-)
@UiField
Content content; // will be populated by UiBinder with your Content
ServiceAsync service;
HandlerManager eventBus;
DockLayoutPanel widget;
public AppControler(ServiceAsync service, HandlerManager eventBus) {
this.service = service;
this.eventBus = eventBus;
widget = binder.createAndBind(this);
}
@Override
public void bind() {
// when I bind you bind we bind!
header.bind();
content.bind();
}
@Override
public void unbind() {
header.unbind();
content.unbind();
}
// the remaining methods will vary,
// depending on your framework of choice
@Override
public void go(Panel panel) {
panel.add(widget);
}
@Override
public View getView() {
return this;
}
@Override
public Widget asWidget() {
return widget;
}
}
On Jan 22, 4:40 pm, Ahmet Recep Navruz <[email protected]> wrote:
> Waiting for the answer too :)
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.