Java 在使用地点和活动导航时,左侧的菜单栏会消失
在我的应用程序中,我希望在所有页面上保持左侧的菜单,但是当我单击左侧的按钮时,我的菜单消失了。我在这里附上我的代码 启动器类:Java 在使用地点和活动导航时,左侧的菜单栏会消失,java,gwt,Java,Gwt,在我的应用程序中,我希望在所有页面上保持左侧的菜单,但是当我单击左侧的按钮时,我的菜单消失了。我在这里附上我的代码 启动器类: public class SmartEBRM implements EntryPoint { //private Place defaultPlace = new SmartEBRMViewPlace("World!"); //private SimplePanel appWidget = new SimplePanel(); @SuppressWarnings("
public class SmartEBRM implements EntryPoint {
//private Place defaultPlace = new SmartEBRMViewPlace("World!");
//private SimplePanel appWidget = new SimplePanel();
@SuppressWarnings("deprecation")
@Override
public void onModuleLoad() {
// TODO Auto-generated method stub
ClientFactory clientFactory = GWT.create(ClientFactory.class);
EventBus eventBus = clientFactory.getEventBus();
PlaceController placeController = clientFactory.getPlaceController();
// Start ActivityManager for the main widget with our ActivityMapper
ActivityMapper activityMapper = new AppActivityMapper(clientFactory);
ActivityManager activityManager = new ActivityManager(activityMapper, eventBus);
SmartEBRMViewImpl smartViewImpl = new SmartEBRMViewImpl();
activityManager.setDisplay (smartViewImpl.getHTMLPannel());
// Start PlaceHistoryHandler with our PlaceHistoryMapper
AppPlaceHistoryMapper historyMapper= GWT.create(AppPlaceHistoryMapper.class);
PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
SmartEBRMViewPlace smartViewPlace = new SmartEBRMViewPlace();
//ClearPannelPlace smartViewPlace = new ClearPannelPlace();
historyHandler.register(placeController, eventBus, smartViewPlace);
historyHandler.handleCurrentHistory();
RootPanel.get().add(smartViewImpl.getHTMLPannel());
}
}
主要观点:
public class SmartEBRMViewImpl extends Composite implements SmartEBRMView{
private static SmartEBRMViewImplUiBinder uiBinder = GWT
.create(SmartEBRMViewImplUiBinder.class);
@UiField DockLayoutPanel docLayoutPanel;
@UiField StackPanel stackPanel;
@UiField Button enterpriseView;
@UiField Button testComponent;
@UiField SimplePanel centerPanel;
@UiField SimplePanel westPanel;
@UiField SimplePanel northPanel;
private Presenter listener;
interface SmartEBRMViewImplUiBinder extends
UiBinder<Widget, SmartEBRMViewImpl> {
}
public SmartEBRMViewImpl() {
initWidget(uiBinder.createAndBindUi(this));
}
public SmartEBRMViewImpl(String firstName) {
initWidget(uiBinder.createAndBindUi(this));
}
@Override
public void setPresenter(Presenter listener) {
// TODO Auto-generated method stub
this.listener = listener;
}
public SimplePanel getHTMLPannel () {
return centerPanel;
}
public SimplePanel getNorthPanel () {
return northPanel;
}
public SimplePanel getWestPanel () {
return westPanel;
}
@UiHandler("enterpriseView")
public void onClearButtonClick(ClickEvent e)
{
listener.goTo(new EnterpriseInvoiceCompareViewPlace());
}
制图员:
public class AppActivityMapper implements ActivityMapper{
private ClientFactory clientFactory;
/**
* AppActivityMapper associates each Place with its corresponding
* {@link Activity}
*
* @param clientFactory
* Factory to be passed to activities
*/
public AppActivityMapper(ClientFactory clientFactory) {
super();
this.clientFactory = clientFactory;
}
/**
* Map each Place to its corresponding Activity. This would be a great use
* for GIN.
*/
@Override
public Activity getActivity(Place place) {
if (place instanceof EnterpriseInvoiceCompareViewPlace){
return new EnterpriseInvoiceCompareActivity((EnterpriseInvoiceCompareViewPlace) place, clientFactory);
}
else if (place instanceof SmartEBRMViewPlace)
return new SmartEBRMViewActivity((SmartEBRMViewPlace) place, clientFactory);
return null;
}
}
地点:
public class EnterpriseInvoiceCompareViewPlace extends Place{
public EnterpriseInvoiceCompareViewPlace()
{
}
public static class Tokenizer implements PlaceTokenizer<EnterpriseInvoiceCompareViewPlace>
{
@Override
public String getToken(EnterpriseInvoiceCompareViewPlace place)
{
return "EntInvoiceCompare";
}
@Override
public EnterpriseInvoiceCompareViewPlace getPlace(String token)
{
return new EnterpriseInvoiceCompareViewPlace();
}
}
}
public class SmartEBRMViewPlace extends Place{
public SmartEBRMViewPlace()
{
}
public static class Tokenizer implements PlaceTokenizer<SmartEBRMViewPlace>
{
@Override
public String getToken(SmartEBRMViewPlace place)
{
return "SmartView";
}
@Override
public SmartEBRMViewPlace getPlace(String token)
{
return new SmartEBRMViewPlace();
}
}
}
公共类EnterpriseInvoiceCompareViewPlace扩展位置{
公共企业InvoiceCompareViewPlace()
{
}
公共静态类标记器实现PlaceTokenizer
{
@凌驾
获取公共字符串(EnterpriseInvoiceCompareViewPlace)
{
返回“EntInvoiceCompare”;
}
@凌驾
公共企业InvoiceCompareViewPlace getPlace(字符串标记)
{
返回新的EnterpriseInvoiceCompareViewPlace();
}
}
}
公共类智能BRMViewPlace扩展位置{
公共智能brmviewplace()
{
}
公共静态类标记器实现PlaceTokenizer
{
@凌驾
公共字符串getToken(智能BRMViewPlace位置)
{
返回“SmartView”;
}
@凌驾
公共智能BRMViewPlace getPlace(字符串令牌)
{
返回新的SmartbrmviewPlace();
}
}
}
如果您想在左侧设置一个静态菜单,那么它不应该是一个活动(如果需要,它仍然可以对
PlaceChangeEvent
事件作出反应),或者您应该在左侧区域设置2个ActivityManager
(无论在哪个位置,都有一个始终返回菜单活动的ActivityMapper
)和中心区域(带有一个ActivityMapper
,根据当前位置返回相应的活动)
顺便说一句,我觉得很奇怪,您将
smartViewImpl.getHTMLPannel()
添加到RootPanel
,而不是smartViewImpl
我最初添加了smartViewImpl,但随后在左侧得到了两个菜单。如果我点击其中一个,我会进入第二个页面,如果我点击最左边的一个,它什么也不做。我没有看你所有的代码,因为代码太多了。我怀疑你还没有完全掌握所有的事情都应该被安排和组织,所以我只能给你一个建议。还有,我发布了一些关于场所和活动的文章,这些文章可能会帮助您理解所有这些。您能建议我应该使用什么代码,以便您可以建议解决方案吗?我是GWT的新手,“地点和活动”完全把我搞糊涂了。
public class AppActivityMapper implements ActivityMapper{
private ClientFactory clientFactory;
/**
* AppActivityMapper associates each Place with its corresponding
* {@link Activity}
*
* @param clientFactory
* Factory to be passed to activities
*/
public AppActivityMapper(ClientFactory clientFactory) {
super();
this.clientFactory = clientFactory;
}
/**
* Map each Place to its corresponding Activity. This would be a great use
* for GIN.
*/
@Override
public Activity getActivity(Place place) {
if (place instanceof EnterpriseInvoiceCompareViewPlace){
return new EnterpriseInvoiceCompareActivity((EnterpriseInvoiceCompareViewPlace) place, clientFactory);
}
else if (place instanceof SmartEBRMViewPlace)
return new SmartEBRMViewActivity((SmartEBRMViewPlace) place, clientFactory);
return null;
}
}
public class EnterpriseInvoiceCompareViewPlace extends Place{
public EnterpriseInvoiceCompareViewPlace()
{
}
public static class Tokenizer implements PlaceTokenizer<EnterpriseInvoiceCompareViewPlace>
{
@Override
public String getToken(EnterpriseInvoiceCompareViewPlace place)
{
return "EntInvoiceCompare";
}
@Override
public EnterpriseInvoiceCompareViewPlace getPlace(String token)
{
return new EnterpriseInvoiceCompareViewPlace();
}
}
}
public class SmartEBRMViewPlace extends Place{
public SmartEBRMViewPlace()
{
}
public static class Tokenizer implements PlaceTokenizer<SmartEBRMViewPlace>
{
@Override
public String getToken(SmartEBRMViewPlace place)
{
return "SmartView";
}
@Override
public SmartEBRMViewPlace getPlace(String token)
{
return new SmartEBRMViewPlace();
}
}
}