GWT中的半动态常数 [英] Semi dynamic constants in GWT

查看:87
本文介绍了GWT中的半动态常数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于GWT,我们使用静态常量为用户提供国际化.但是,这使审阅和编辑文本成为一个繁琐的过程,因为如果我们的利益相关者之一提出了意见,则必须将其重新编译并部署到我们的演示环境中.解决方案是使用某种半动态文本常量.

For GWT we use static constants to provide internationalization for our users. However, this makes reviewing and editing the texts a tedious process, because if one of our stakeholders has comments, it has to be compiled and deployed to our demo environment again. The solution would be to have some kind of semi dynamic text constants.

我想要的是,我可以编译为某种查看模式",并且当我这样做时,可以从服务器或数据库的文件中读取常量.如果可能的话,我希望能够编辑此文件,以便涉众可以自己修改文本(使用某种我必须为此编写的文本编辑小部件).然后,我们可以使用这些文本进行开发,测试和演示.如果满意的话,我们会针对生产模式进行编译,该生产模式将使用完全在JavaScript中编译的老式常量资源束.

What I would like, is that I can compile to some kind of "review mode", and when I do that, the constants are read from a file from the server or database. If possible I would like to be able to edit this file, so stakeholders can modify the texts themselves (using some kind of text edit widget I would have to write for that). Then we can develop, test and demo with these texts. If we are satisfied, we compile for production mode, which uses a old fashioned constants resource bundle, compiled completely in JavaScript.

有人知道是否存在类似的东西,或者是否有实现此目标的指针?

Does somebody know if something like this exists, or have some pointers on how to implement this?

推荐答案

GWT程序员经常忽略JSP和Dictionary类的用处,这是一个非常令人惊讶的情况.即使我们中的许多人在使用GWT之前都有大量的JSP经验.

It is a very surprising situation that GWT programmers often overlook the usefulness of JSPs and the Dictionary class. Even though many of us had tons of JSP experience prior to using GWT.

词典类

您可以在html托管文件中将静态"信息定义为javascript var对象.在模块加载后,可以随时使用Dictionary类读取那些javascript对象.

You can define your "static" information as javascript var objects in the html hosting file. The Dictionary class can be used to read those javascript objects any time after moduleload.

JSP

HTML托管"文件(即用于启动GWT的html文件)不必是HTML文件.它可以是JSP动态生成的HTML文件.

The HTML "hosting" file, i.e. the html file used for launching GWT need not be an HTML file. It can be a HTML file dynamically generated by a JSP.

如果您熟悉JSP,则可以通过更改扩展名将HTML文件转换为JSP.现在,将用于定义GWT静态"信息的javascript对象部分转变为由JSP动态生成.

If you are familiar with JSP, you could turn an HTML file into a JSP just by changing its extension. Now turn the javascript object section you used for defining GWT "static" information into being dynamically generated by the JSP.

Voila!

当我需要为GWT客户端生成特定于用户或会话的静态"信息时,我将JSP用作托管文件. JSP可以从数据库或从某些条件选择的文本文件中读取.

I use JSP as the hosting file when I need to generate user- or session- specific "static" information for the GWT client. The JSP could read from the database or from some conditionally chosen text files.

这篇关于GWT中的半动态常数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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