Tôi đang sử dụng GWT MVP và UiBinder để tạo ứng dụng với DockLayoutPanel. Tôi muốn các bến cảng phía bắc và phía nam tĩnh, chứa các nút và liên kết. Tôi muốn có quan điểm năng động ở trung tâm và hai khu vực khác nhau của bến tàu phía đông. Vì các vùng động này phải độc lập với nhau, tôi thiết lập các ActivityMapper và ActivityManager khác nhau cho từng vùng hiển thị động; trung tâm, phía đông và phía đông.Cách thực hiện: UiBinder + GWT MVP + nhiều khu vực hiển thị độc lập
Tôi làm cách nào để khởi tạo độc lập 3 khu vực hiển thị khác nhau khi ứng dụng được tải? Làm cách nào để chuyển từ một Hoạt động này sang một Hoạt động khác trong một khu vực hiển thị mà không ảnh hưởng đến các khu vực khác?
Khi tôi sử dụng goTo của PlaceController để chuyển từ một địa điểm này sang địa điểm khác trong một khu vực, hoạt động của khu vực khác bị dừng.
Mayday, xin vui lòng trợ giúp, mayday!
Sau đây là một số mã của tôi:
AppViewImpl.ui.xml
<g:DockLayoutPanel styleName="{style.dockPanel}" unit="PX" width="975px" height="100%">
<!-- DOCK PANEL EAST -->
<g:east size="220">
<g:LayoutPanel styleName="{style.eastPanel}">
<g:layer left="0px" width="220px" top="0px" height="105px">
<g:SimpleLayoutPanel ui:field="topRightPanel"/>
</g:layer>
<g:layer left="0px" width="220px" top="110px" height="340px">
<g:InlineLabel styleName="{style.label}" text="ANOTHER DISPLAY AREA"/>
</g:layer>
</g:LayoutPanel>
</g:east>
<!-- DOCK PANEL NORTH -->
<g:north size="110">
<g:LayoutPanel styleName="{style.northPanel}">
<g:layer left="0px" width="755px" top="0px" height="105px">
<g:InlineLabel styleName="{style.label}" text="NORTH PANEL"/>
</g:layer>
</g:LayoutPanel>
</g:north>
<!-- DOCK PANEL SOUTH -->
<g:south size="20">
<g:LayoutPanel styleName="{style.southPanel}">
<g:layer left="0px" width="755px" top="0px" height="20px">
<g:InlineLabel styleName="{style.label}" text="SOUTH PANEL"/>
</g:layer>
</g:LayoutPanel>
</g:south>
<!-- DOCK PANEL CENTER -->
<g:center>
<g:SimpleLayoutPanel ui:field="mainPanel" />
</g:center>
</g:DockLayoutPanel>
MyModule.java
public class MyModule thực hiện EntryPoint {
private Place defaultPlace = new DefaultPlace("");
public void onModuleLoad() {
// Create ClientFactory using deferred binding so we can replace with
// different impls in gwt.xml
ClientFactory clientFactory = GWT.create(ClientFactory.class);
EventBus eventBus = clientFactory.getEventBus();
PlaceController placeController = clientFactory.getPlaceController();
// Start ActivityManager for the main widget with our ActivityMapper
ActivityMapper topRightActivityMapper = new TopRightActivityMapper(clientFactory);
ActivityManager topRightActivityManager = new ActivityManager(topRightActivityMapper, eventBus);
topRightActivityManager.setDisplay(clientFactory.getAppView().getTopRightPanel());
// Start ActivityManager for the main widget with our ActivityMapper
ActivityMapper mainActivityMapper = new AppActivityMapper(clientFactory);
ActivityManager mainActivityManager = new ActivityManager(mainActivityMapper, eventBus);
mainActivityManager.setDisplay(clientFactory.getAppView().getMainPanel());
// Start PlaceHistoryHandler with our PlaceHistoryMapper
AppPlaceHistoryMapper historyMapper = GWT .create(AppPlaceHistoryMapper.class);
PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
historyHandler.register(placeController, eventBus, defaultPlace);
RootLayoutPanel.get().add(clientFactory.getAppView());
// Goes to place represented on URL or default place
historyHandler.handleCurrentHistory();
new AppController(clientFactory);
}
}
AppController.java
public class AppController implements AppView.Presenter {
private ClientFactory clientFactory;
AppController(ClientFactory clientFactory){
this.clientFactory = clientFactory;
goTo(new TopRightAPlace(""));
}
@Override
public void goTo(Place place) {
clientFactory.getPlaceController().goTo(place);
}
}
TopRightAViewImpl.java
public class TopRightAViewImpl extends Composite implements TopRightAView {
interface Binder extends UiBinder<Widget, TopRightAViewImpl> {
}
private static final Binder binder = GWT.create(Binder.class);
private Presenter listener;
@UiField
Button button;
public TopRightAViewImpl() {
initWidget(binder.createAndBindUi(this));
}
@Override
public void setName(String name) {
button.setHTML(name);
}
@Override
public void setPresenter(Presenter listener) {
this.listener = listener;
}
@UiHandler("button")
void onButtonClick(ClickEvent event) {
listener.goTo(some other place);
}
}
Đây chính xác là những gì tôi đã làm. Cảm ơn! – Pete