如何使用GWT 2.4动态创建UI,服务器端 [英] How to create UI dynamically, server-side, with GWT 2.4

查看:91
本文介绍了如何使用GWT 2.4动态创建UI,服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Web Toolkit v2.4创建用户界面。由于各种原因,我需要在运行时指定服务器上接口的内容。我不只是说按钮需要动态标签等,而是需要在运行时创建整个UI。



我的用户界面的大部分都可以指定作为直接的HTML。但我也想要Scrollpane这样的小工具。当然,我需要以某种方式将操作附加到按钮之类的东西上。

我尝试通过创建com.google.gwt.user.client.ui.Button的实例来创建UI服务器端,并通过RPC调用将它们返回给客户端。但是,Button类不可序列化。 (包名也告诉我这是一个只能在客户端上运行的对象)。



我考虑在运行中生成一个UiBinder模板。然而,它似乎需要编译UI粘合剂模板。



现在我正在寻找使用占位符XML元素向客户端发送HTML的GWT小部件应该去的地方。在客户端,我会使用DOM方法来查找并用GWT小部件替换它们。但感觉我已经走得很远了,在这一点上。



感觉应该有一个简单的方法来做到这一点,但它却让我无法回避。



建议?

解决方案

GWT没有内置的支持像这样的东西(因为它完全没有gwt的点)。
所以你有两个选择,

构建你自己的框架,所以你将能够从服务器发送一些布局页面数据给客户端,客户端会解析它并会创建ui





您可以使用其他框架,例如 Vaadin 基本上可以做你想做的,或者是一些JavaScript UI Framework + Node.js的组合,你可以在其中轻松地分享客户端和服务器之间的代码。


I'm trying to create a user interface using Google Web Toolkit v2.4. For a variety of reasons, I need to specify the contents of the interface on the server, at run-time. I don't just mean the the buttons need dynamic labels etc, but rather the whole UI needs to be created at run-time.

Much of my UI can be specified as straight-forward HTML. But I also want widgets like Scrollpane. Of course I need to somehow attach actions to things like buttons.

I tried creating the UI server-side by creating instances of com.google.gwt.user.client.ui.Button, and returning them to the client via RPC call. However the Button class is not serializable. (Also the package name is telling me this is an object which should live on the client only.)

I considered generating a UiBinder template on the fly. However it seems UI binder templates need to be compiled.

I'm now looking at sending HTML to the client with placeholder XML elements where the GWT widgets should go. On the client, I would use DOM methods to find and replace them with GWT widgets. But it feels I've gone far astray, at this point.

It feels like there should be a straight-forward way to do this, but it is eluding me.

Suggestions?

解决方案

GWT has no built-in support for stuff like this (since it is totally missing the point of gwt). So you have two choices,

build your own framework, so you will be able to send from server to client some layout page data, client will parse it and will create ui

or

you can use some other framework, for example Vaadin which basically does what you want, or a combination of some JavaScript UI Framework + Node.js where you can easily share the code between client and server.

这篇关于如何使用GWT 2.4动态创建UI,服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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