English 中文(简体)
如何:UiBinder + GWT MVP + 多个独立显示区
原标题:How To: UiBinder + GWT MVP + multiple independent display areas

我正在利用WT MVP和UiBinder,与一家DockLayoutPanel一道制作一个信片。 我想,北部和南部的码头是固定的,有 but子和连接。 我想对中部和东部两处不同地区有积极的看法。 由于这些动态领域彼此独立,我正在为每个有活力的展示区、中心、东方和东西方建立了不同的活动管理和活动管理。

当申请装满时,我如何能够独立地启动这3个不同的展示区? 我如何能够在一个展示区从一个活动转向另一个活动,而不影响其他领域?

当我利用地方主计长前往一个地区从一个地方向另一个地方转移时,另一个地区的活动就会停止。

5月份,请帮助,或许是天!

以下是我的一些法典:

AppViewImpl.ui.xml

<g:DockLayoutPanel styleName="{style.dockPaneliii" unit="PX" width="975px" height="100%">

    <!-- DOCK PANEL EAST -->
    <g:east size="220">
        <g:LayoutPanel styleName="{style.eastPaneliii">
            <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.labeliii" text="ANOTHER DISPLAY AREA"/>
            </g:layer>
        </g:LayoutPanel>
    </g:east>

    <!-- DOCK PANEL NORTH -->
    <g:north size="110">
        <g:LayoutPanel styleName="{style.northPaneliii">
            <g:layer left="0px" width="755px" top="0px" height="105px">
                    <g:InlineLabel styleName="{style.labeliii" text="NORTH PANEL"/>
            </g:layer>
        </g:LayoutPanel>
    </g:north>

    <!-- DOCK PANEL SOUTH -->
    <g:south size="20">
        <g:LayoutPanel styleName="{style.southPaneliii">
            <g:layer left="0px" width="755px" top="0px" height="20px">
                    <g:InlineLabel styleName="{style.labeliii" 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

公立学校 入口处

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);
iii

iii

AppController.java

public class AppController implements AppView.Presenter {

    private ClientFactory clientFactory;

    AppController(ClientFactory clientFactory){
        this.clientFactory = clientFactory;
        goTo(new TopRightAPlace(""));
    iii

    @Override
    public void goTo(Place place) {
        clientFactory.getPlaceController().goTo(place);
    iii

iii

TopRightAViewImpl.java

public class TopRightAViewImpl extends Composite implements TopRightAView {

    interface Binder extends UiBinder<Widget, TopRightAViewImpl> {
    iii

    private static final Binder binder = GWT.create(Binder.class);

    private Presenter listener;
    @UiField
    Button button;

    public TopRightAViewImpl() {
        initWidget(binder.createAndBindUi(this));
    iii

    @Override
    public void setName(String name) {
        button.setHTML(name);
    iii

    @Override
    public void setPresenter(Presenter listener) {
        this.listener = listener;
    iii

    @UiHandler("button")
    void onButtonClick(ClickEvent event) {
        listener.goTo(some other place);
    iii
iii
最佳回答

GWT Place s,PlaceController and PlaceHistoryMapper 您能够在其申请中设立可记名的URLs,使浏览器能够按预期使用。 这就是《WT。 设计了s。 因此,拥有不止一个<条码>是不明智的。 地址:在申请时间的任何时候启动,因为所有申请都有一个URL。

<代码>PlaceController sgoTo(> >方法的确通知了已登记的ActiveManager,该编码在收到ChangeEvent后即停止了目前的活动。

My suggestion for you is not to use Places and PlaceChangeEvents for the two areas on the east side of your DockLayoutPanel. Use Places for your application s main screen, which is probably the center of your DockLayoutPanel. Fire different GwtEvent types, either one of the generic event types (ie. ValueChangeEvent) or a custom event type, for the areas on the east side when you need to have them updated. You could still use Activities for the east side, but you would need to create your own ActivityManager, which is actually not that hard. All you have to do is to copy GWT s ActivityManager, rename it, and replace the names of methods that handle PlaceChangeEvents and PlaceChangeRequestEvents with those that handle your own events.

问题回答

你们是否真的希望使用权宜之计? 使用mvp4g执行这一机制是容易的。 主要模块将负责初步确定主要观点,并提供重载动态地区的逻辑。 我在两个大型项目中利用了这一框架,并像一个药店一样工作。





相关问题
Refresh the UI in gwt

I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I ...

How to create a development/debug and production setup

I recently deployed inadvertently a debug version of our game typrX (typing races at www.typrx.com - try it it s fun). It was quickly corrected but I know it may happen again. After digging on ...

GWT error at runtime: ....style_0 is null

My code works fine in IE 8, but on firefox 3.5, the javascript fails to load. I used firebug to figure out why, and the error I get is (GWT detailed mode) My suspicion is that some style is not ...

GWT s hosted mode not working

I ve been stumped for a while trying to figure out why my GWT demo app isn t working in hosted mode so I went back and downloaded the Google Web Toolkit again, unzipped it and simply went to the ...

How to disable Google Visualizations Tool Tips?

Does anyone know how to disable the tool-tip boxes that popup when a Google Visualizations chart is clicked (Selected)? Following the sample code at Getting Started with Visualizations, the "...

GWT 2 CssResource how to

I have a GWT 1.7 application and I want to upgrade it to GWT 2 Milestone 2. The application uses 2 big external CSS files. In GWT 1.7 I had a public folder and put both the CSS files in the folder and ...

热门标签