用于单独 HTML 页面的 GWT 多模块? [英] GWT multi modules for separate HTML pages?

查看:20
本文介绍了用于单独 HTML 页面的 GWT 多模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 GWT 很陌生,打算使用 GWT 为用户管理应用程序开发 UI.我打算使用使用 Spring/Hibernate 创建的现有模块.我想出了如何将 GWT 与 Spring 集成,但我不确定如何设计布局.

I am quite new to GWT and going to develop the UI for user-management application using GWT. I am planning to use existing module which created using Spring/Hibernate. I figured out how to integrate GWT with Spring but I am not sure how to design the layout.

我想要两页:

  1. 用户注册页面(想在 HTML 中嵌入 GWT 小部件)
  2. 管理页面(单独的 HTML,嵌入了 GWT 小部件)
  3. 我打算使用 Spring Security,是使用简单的 JSP 登录页面还是可以使用 RIA GWT 登录小部件?

我可以用什么来满足上述要求?多个 GWT 模块?

What can I use for above requirements? multiple GWT modules?

推荐答案

您可以制作 2 个模块,一个用于登录小部件,另一个用于管理小部件.每个小部件都会将自己插入到您想要的任何 html(或 jsp)页面中的 div 中.

You could make 2 modules, one for the login widget, and another for the admin widget. Each widget will insert itself into a div in whichever html (or jsp) page you want.

例如为每个模块创建一个*.gwt.xml,例如:login.gwt.xml 和admin.gwt.xml.这些文件都应该在您的 gwt 包的根目录下创建,例如:com.gwt.example.

For example, create a *.gwt.xml for each module, for example: login.gwt.xml and admin.gwt.xml. These files should both be created at the root of your gwt package, for example: com.gwt.example.

接下来,为每个类创建一个入口点"类(每个类将实现 EntryPoint).例如,Login.java 可能看起来像:

Next, create an "Entry Point" class for each (each class will implement EntryPoint). For example, Login.java might look like:

package com.gwt.example.myproject.client;

public class Login implements EntryPoint {

  public void onModuleLoad() {
    ... create loginWidget ..

    RootPanel.get("my-login-div").add(loginWidget);

  }

}

所以,现在,当您进行 gwt 编译时,它应该在 war/com.gwt.example 下创建一堆文件.您感兴趣的两个是 com.gwt.example.login.nocache.jscom.gwt.example.admin.nocache.js.

So, now, when you do a gwt compile, it should create a bunch of files under war/com.gwt.example. The two you're interested in are com.gwt.example.login.nocache.js and com.gwt.example.admin.nocache.js.

现在,您可以根据需要将这两个 js 脚本添加到任何 html 和/或 jsp 页面中.

Now, you can add these two js scripts into any html and/or jsp page as needed.

要完成示例,您可以添加以下 html 以添加登录小部件:

To complete the example, you could add the following html to add the login widget:

<html>
....other stuff...
<script type="text/javascript" language="javascript" src="com.gwt.example.login.nocache.js"></script>
....other stuff....
<div id="my-login-widget"></div>
....the rest of your html markup....
</html>

因此,当您浏览到此 html 页面时,它会加载已编译的 gwt javascript,它知道加载 onModuleLoad,它会查找 id="my-login-widget" 的 div 并插入登录小部件.

So, when you browse to this html page, it loads compiled gwt javascript, which knows to load onModuleLoad, which looks for div with id="my-login-widget" and inserts the login widget.

我从未使用过 Spring Security,所以除了这篇文章之外,没有太大帮助 看起来它可能描述了如何使 Spring Security 在 ajax 上工作.

I've never used Spring Security, so can't be much help, other than this article looks like it might describe how to make Spring Security work over ajax.

这篇关于用于单独 HTML 页面的 GWT 多模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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