GWT多个html页面和导航 [英] GWT Multiple html pages and navigation

查看:143
本文介绍了GWT多个html页面和导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我想提一下,我知道基于ajax的应用程序和重用相同的页面。



这里的要求是,我想要两个单独的第一页用于登录,另一页用于主应用程序。现在,这不是因为我只是想要它,而是因为我在两个页面中有非常不同的布局,我可以直接在页面中将html元素和css放在一起,然后将div包含用于gwt填充的动态html 。

即使在myfaces的情况下,我也没有看到用于登录和主应用程序页面的应用程序。
无论如何,我面临的问题是,让我说我有两页



Login.html与div:div id =login



Main.html带div:div id =main



我已经在我的欢迎文件中声明了它们两个在web.xml
列表现在我开始登录页面使用gwt小部件填写登录div,并点击按钮
i使用以下jsni代码重定向到/Main.html?gwt。 codevr = 127.0.0.1:9997



私有本地void gotoURL(String url)/ - {
$ wnd.location.href = url;
} -
/;

然后尝试填充主div。但是,我注意到的行为是,应用程序再次调用入口点,它没有找到任何元素作为登录,并给予NPE。
有没有办法做到这一点?还要摆脱?gwt.codesvr = 127.0.0.1:9997?



谢谢

解决方案

首先,你不想添加?gwt.codesvr = ... 东西 - 它只与托管(调试的gwt)模式。你可以使用相对的URL(例如简单的Main.html)。但是由于您只能拥有一个入口点,因此您需要将应用拆分为两个客户端模块(实际上是两个独立的应用)或根据url在入口点发送(无论您是登陆Login.html还是Main第二,在这种情况下我会做的是有一个空的HTML,没有布局,除了动态内容的唯一div作为唯一的html页面应用程序。然后,我会使用2个UiBinders - 一个用于主页面,另一个用于登录,并使用URL中的哈希后缀(使用GWT的历史事件和管理以及超链接小部件)来了解我的位置。也许你应该阅读GWT关于历史和有状态应用程序的文档。尝试 http://code.google.com/webtoolkit/doc/latest/ DevGuideCodingBasicsHistory.html#stateful


Hi firstly i want to mention that i am aware of ajax based application and reuse of same page.

The requirement here is that, i want to have two separate pages one for login and other for the main application. Now, this is not because i just want it, but because i have very different layouts in the two pages which i am comfortable to put together with html elements and css directly in the page and then putting divs to contain dynamic html for gwt to populate.

Even in case of myfaces i have not seen application with same page for login and the main app page. Anyways, the problem i am facing is, lets say i have two pages

Login.html with a div : div id="login"

Main.html with a div: div id="main"

i have declared both of them in my welcome file list in web.xml Now i start with Login page fill the "login" div with gwt widgets and on click of a button i am using following jsni code to redirect to "/Main.html?gwt.codesvr=127.0.0.1:9997"

private native void gotoURL(String url) /-{ $wnd.location.href=url; }-/;

and then trying to populate the "main" div. But the behaviour as i noticed is that the application call the entry point again and it doesnt find any element as "login" and gives NPE. Is there a way to do this? also to get rid of the "?gwt.codesvr=127.0.0.1:9997"?

Thanks

解决方案

First, you don't want to add the ?gwt.codesvr=... stuff - it's related only to hosted (debugging of gwt) mode. You could use a relative url (for example simply "Main.html"). But since you can only have a single entry point, you need to either split the app into two client modules (two separate apps actually) or dispatch in your entry point according to the url (whether you've landed on Login.html or Main.html)

Second, what I would do in this scenario is have an empty html with no layout except a single div for the dynamic content as the only html page of the app. Then I would use 2 UiBinders - one for the main page, and one for login, and use a hash suffix in the url (using GWT's history event and management, and hyperlink widgets) to know where I am. Maybe you should read more in GWT's documentation on history and stateful apps. Try http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsHistory.html#stateful

这篇关于GWT多个html页面和导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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