GWT的RootLayoutPanel - 问题渲染页面从第二到第一(第一次正常工作) [英] GWT RootLayoutPanel - Problem rendering page from second to first (first works fine)

查看:184
本文介绍了GWT的RootLayoutPanel - 问题渲染页面从第二到第一(第一次正常工作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,如果这已经回答过。我做了一点搜索,发现什么都不能解决我的问题。我使用Spring Roo创建了一个应用程序,然后转换为GWT应用程序。
Spring Roo生成的所有代码仅适用于CRUD。现在我想添加约会日历,所以我需要移动到另一个页面。
我已将此代码添加到

ScaffoldDesktopShell.java()

  public Sc​​affoldDesktopShell(){
initWidget(BINDER.createAndBindUi(this));
startButton.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event){
RootLayoutPanel.get()。add(new NovoPainel());
}
});
}
...

然后创建一个新的UIbinder,称之为<

  public NovoPainel(){
initWidget(uiBinder .createAndBindUi(本));

botao.addClickHandler(new ClickHandler(){
$ b $ @覆盖
public void onClick(ClickEvent event){
RootLayoutPanel.get()。clear ();
RootLayoutPanel.get()。add(new ScaffoldDesktopShell());
}
});
}

从我的根面板移动到NovoPainel一切都很顺利,但是当我需要回到rootPanel页面不能正确呈现。
EX:不显示** ValuePicker **点击左侧面板并在中心呈现。



这是我的RootPanel



这张图片是从rootPanel导航到NovoPainel的时候




最后这个从NovoPainel返回到RootPanel

解决方案



Roo生成的代码隐藏了中的大多数行为, _Roo_Gwt 类,这是因为。


Sorry if this was already answered before. I did a little searching and found nothing that could solve my problem. I created an application with Spring Roo, then converted to a GWT app. All the code generated by Spring Roo is only for CRUD. Now i want to add a Calendar for make appointments, so i need to move to another page. I´ve added this code to
ScaffoldDesktopShell.java()

    public ScaffoldDesktopShell() {
            initWidget(BINDER.createAndBindUi(this));
                startButton.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        RootLayoutPanel.get().add(new NovoPainel());    
                    }
                });
            }
...    

Then created a new UIbinder, called it NovoPainel() and added this code:

public NovoPainel() {
    initWidget(uiBinder.createAndBindUi(this));

    botao.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {             
            RootLayoutPanel.get().clear(); 
            RootLayoutPanel.get().add (new ScaffoldDesktopShell()); 
        }
    });
} 

Everything goes fine moving from my root panel to NovoPainel, but when i need to go back to rootPanel the page doesn´t render correctly. EX: Doesn´t show ** ValuePicker ** to click on left panel and render on center.

This is my RootPanel

and this image is when navigate from rootPanel to NovoPainel

and finally this one is returning from NovoPainel to RootPanel

解决方案

You have to integrate with Roo generated architecture so that you can still benefit from Roo scaffolding.

Roo generated code hides most of behavior in _Roo_Gwt classes and it is because GWT doesn’t currently support ITDs. So changes have to be made in derived classes by overriding methods from _Roo_Gwt class.

To navigate application use Places, ActivityMapper and ActivitiManager (you can find good read on @Thomas Broyer posterous and GWT help).

If you take a look in ScaffoldDesktopShell.ui.xml - page is devided in three main areas. ApplicationMasterActivities class is responsible for master area.

masterActivityManager.setDisplay(shell.getMasterPanel());

proxyListPlacePicker in ScaffoldDesktopApp.init() generates place change event with apropriate ProxyListPlace.

public void onValueChange(ValueChangeEvent<ProxyListPlace> event) {
    placeController.goTo(event.getValue());
}

ApplicationMasterActivities class creates appropriate Activity in Master area by checking EntityProxy type contained in ProxyListPlace object.

public Activity getActivity(Place place) {
    if (!(place instanceof ProxyListPlace)) {
        return null;
    }
    ProxyListPlace listPlace = (ProxyListPlace) place;
    return new ApplicationEntityTypesProcessor<Activity>() {

        @Override
        public void handlePet(PetProxy isNull) {
            setResult(new PetListActivity(requests, ScaffoldApp.isMobile() ? PetMobileListView.instance() : PetListView.instance(), placeController));
        }

        @Override
        public void handleOwner(OwnerProxy isNull) {
            setResult(new OwnerListActivity(requests, ScaffoldApp.isMobile() ? OwnerMobileListView.instance() : OwnerListView.instance(), placeController));
        }
    }.process(listPlace.getProxyClass());
}

Navigation is created by listing all EntityProxy's in ScaffoldApp class

protected HashSet<ProxyListPlace> getTopPlaces() {
    Set<Class<? extends EntityProxy>> types = ApplicationEntityTypesProcessor.getAll();
    HashSet<ProxyListPlace> rtn = new HashSet<ProxyListPlace>(types.size());

    for (Class<? extends EntityProxy> type : types) {
        rtn.add(new ProxyListPlace(type));
    }

    return rtn;
}

To output meaningfull name in navigation menu they are rendered using ApplicationListPlaceRenderer

public String render(ProxyListPlace object) {
    return new ApplicationEntityTypesProcessor<String>() {

        @Override
        public void handlePet(PetProxy isNull) {
            setResult("Pets");
        }

        @Override
        public void handleOwner(OwnerProxy isNull) {
            setResult("Owners");
        }
    }.process(object.getProxyClass());
}

So you have to create new Activity. public class SomeActivity extends Composite implements Activity{

private static SomeActivityUiBinder uiBinder = GWT
        .create(SomeActivityUiBinder.class);

interface SomeActivityUiBinder extends UiBinder<Widget, SomeActivity> {
}

private AcceptsOneWidget display;

public SomeActivity() {
    initWidget(uiBinder.createAndBindUi(this));
}

@Override
public String mayStop() {
    return null;
}

@Override
public void onCancel() {
    onStop();

}

@Override
public void onStop() {
    this.display.setWidget(null);
}

@Override
public void start(AcceptsOneWidget panel, EventBus eventBus) {
    this.display = panel;
    this.display.setWidget(this);
}

}


<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
   <g:HTMLPanel>
    Hello world!
   </g:HTMLPanel>
</ui:UiBinder> 

Create appropriate EntityProxy. It is only to obey ProxyListPlace mechanism.

public interface SomeEntityProxy extends EntityProxy {
}

Create SomeActivity in A

@Override
public Activity getActivity(Place place) {
    if (!(place instanceof ProxyListPlace)) {
        return null;
    }
    Activity activity = super.getActivity(place);
    if (activity == null) {
        ProxyListPlace listPlace = (ProxyListPlace) place;
            if (SomeEntityProxy.class.equals(listPlace.getProxyClass())) {
                 activity = new SomeActivity();
            }
     }
     return activity;
}

Add place to navigation in ScaffoldApp or override getTopPlaces in derived class.

rtn.add(new ProxyListPlace(SomeEntityProxy.class));

Set correct menu rendering text in ApplicationListPlaceRenderer

@Override
public String render(ProxyListPlace object) {
    String label = super.render(object);
    if(label == null) {
         if (SomeEntityProxy.class.equals(object.getProxyClass())) {
             label = "Some activity";
         }
     }
     return label;
}

Code in GitHub.

这篇关于GWT的RootLayoutPanel - 问题渲染页面从第二到第一(第一次正常工作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆