GWT: How to create a new page

前端 未结 4 1477
攒了一身酷
攒了一身酷 2020-12-03 23:32

I have a GWT MVP application with one page. How can I create a new page and link to it?

4条回答
  •  -上瘾入骨i
    2020-12-04 00:01

    I created a open source, MIT licensed project to ease the page navigation handling in GWT. Take a look at the GWT Views project.

    Using it you can define a View (a Widget referenced by an unique URL token) using simple Java annotations. The framework takes care of code-splitting for you, and hides all the boilerplate code.

    Here is an example:

    @View(Login.TOKEN)
    public class Login extends Composite {
    //... your code, you can use UIBinder, procedural UI, whatever you like
    

    When using History.newItem(Login.TOKEN) the Login widget will be rendered at the page.

    There are a lot of common use cases handled by the framework as well, such as ViewContainers, 404 pages, Google Analytics tracking, and user authorization.

提交回复
热议问题