- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在关注 internationalization chapter .完成将内容翻译成德语的步骤后,当我尝试在浏览器中加载页面时出现此错误:
11:26:27.142 [ERROR] [stockwatcher] Error while executing the JavaScript provider for property 'locale'
com.google.gwt.core.client.JavaScriptException: (TypeError): Property 'locale' of object is not a function
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.ModuleSpacePropertyOracle.computePropertyValue(ModuleSpacePropertyOracle.java:193)
at com.google.gwt.dev.shell.ModuleSpacePropertyOracle.getSelectionProperty(ModuleSpacePropertyOracle.java:130)
at com.google.gwt.i18n.rebind.LocaleUtils.getInstance(LocaleUtils.java:85)
at com.google.gwt.i18n.rebind.LocaleInfoGenerator.generate(LocaleInfoGenerator.java:101)
at com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:48)
at com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:60)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:647)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:78)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:268)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:585)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.google.gwt.i18n.client.LocaleInfo.<clinit>(LocaleInfo.java:37)
at com.google.gwt.user.client.ui.HasHorizontalAlignment.<clinit>(HasHorizontalAlignment.java:123)
at com.google.gwt.user.client.ui.VerticalPanel.<init>(VerticalPanel.java:31)
at com.google.gwt.sample.stockwatcher.client.StockWatcher.<init>(StockWatcher.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:375)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:722)
11:26:27.640 [ERROR] [stockwatcher] Unable to load module entry point class com.google.gwt.sample.stockwatcher.client.StockWatcher (see associated exception for details)
com.google.gwt.dev.shell.BrowserChannel$RemoteDeathError: Remote connection lost
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:356)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
at com.google.gwt.dev.shell.ModuleSpace.displayErrorGlassPanel(ModuleSpace.java:616)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:401)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:722)
Caused by: com.google.gwt.dev.shell.BrowserChannelException: Invalid message type PROTOCOL_VERSION received waiting for return.
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:350)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
at com.google.gwt.dev.shell.ModuleSpace.displayErrorGlassPanel(ModuleSpace.java:616)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:401)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:722)
11:26:27.959 [ERROR] [stockwatcher] Failed to load module 'stockwatcher' from user agent 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2' at localhost:52343
package com.google.gwt.sample.stockwatcher.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import java.util.ArrayList;
import java.util.Date;
public class StockWatcher implements EntryPoint {
private static final int REFRESH_INTERVAL = 5000;
private VerticalPanel mainPanel = new VerticalPanel(); //line 29
private FlexTable stocksFlexTable = new FlexTable();
private HorizontalPanel addPanel = new HorizontalPanel();
private TextBox newSymbolTextBox = new TextBox();
private Button addStockButton = new Button("Add");
private Label lastUpdatedLabel = new Label();
private ArrayList<String> stocks = new ArrayList<String>();
private StockWatcherConstants constants = GWT.create(StockWatcherConstants.class);
/**
* Entry point method.
*/
public void onModuleLoad() {
// Set the window title, the header text, and the Add button text.
Window.setTitle(constants.stockWatcher());
RootPanel.get("appTitle").add(new Label(constants.stockWatcher()));
addStockButton = new Button(constants.add());
// Create table for stock data.
stocksFlexTable.setText(0, 0, constants.symbol());
stocksFlexTable.setText(0, 1, constants.price());
stocksFlexTable.setText(0, 2, constants.change());
stocksFlexTable.setText(0, 3, constants.remove());
// Add styles to elements in the stock list table.
stocksFlexTable.setCellPadding(6);
stocksFlexTable.getRowFormatter().addStyleName(0, "watchListHeader");
stocksFlexTable.addStyleName("watchList");
stocksFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");
stocksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");
stocksFlexTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");
// Assemble Add Stock panel.
addPanel.add(newSymbolTextBox);
addPanel.add(addStockButton);
addPanel.addStyleName("addPanel");
// Assemble Main panel.
mainPanel.add(stocksFlexTable);
mainPanel.add(addPanel);
mainPanel.add(lastUpdatedLabel);
// Associate the Main panel with the HTML host page.
RootPanel.get("stockList").add(mainPanel);
// Move cursor focus to the input box.
newSymbolTextBox.setFocus(true);
// Setup timer to refresh list automatically.
Timer refreshTimer = new Timer() {
@Override
public void run() {
refreshWatchList();
}
};
refreshTimer.scheduleRepeating(REFRESH_INTERVAL);
// Listen for mouse events on the Add button.
addStockButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
addStock();
}
});
// Listen for keyboard events in the input box.
newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
addStock();
}
}
});
}
/**
* Add stock to FlexTable. Executed when the user clicks the addStockButton or
* presses enter in the newSymbolTextBox.
*/
private void addStock() {
final String symbol = newSymbolTextBox.getText().toUpperCase().trim();
newSymbolTextBox.setFocus(true);
// Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
if (!symbol.matches("^[0-9a-zA-Z\\.]{1,10}$")) {
Window.alert("'" + symbol + "' is not a valid symbol.");
newSymbolTextBox.selectAll();
return;
}
newSymbolTextBox.setText("");
// Don't add the stock if it's already in the table.
if (stocks.contains(symbol))
return;
// Add the stock to the table.
int row = stocksFlexTable.getRowCount();
stocks.add(symbol);
stocksFlexTable.setText(row, 0, symbol);
stocksFlexTable.setWidget(row, 2, new Label());
stocksFlexTable.getCellFormatter().addStyleName(row, 1, "watchListNumericColumn");
stocksFlexTable.getCellFormatter().addStyleName(row, 2, "watchListNumericColumn");
stocksFlexTable.getCellFormatter().addStyleName(row, 3, "watchListRemoveColumn");
// Add a button to remove this stock from the table.
Button removeStockButton = new Button("x");
removeStockButton.addStyleDependentName("remove");
removeStockButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
int removedIndex = stocks.indexOf(symbol);
stocks.remove(removedIndex);
stocksFlexTable.removeRow(removedIndex + 1);
}
});
stocksFlexTable.setWidget(row, 3, removeStockButton);
// Get the stock price.
refreshWatchList();
}
/**
* Generate random stock prices.
*/
private void refreshWatchList() {
final double MAX_PRICE = 100.0; // $100.00
final double MAX_PRICE_CHANGE = 0.02; // +/- 2%
StockPrice[] prices = new StockPrice[stocks.size()];
for (int i = 0; i < stocks.size(); i++) {
double price = Random.nextDouble() * MAX_PRICE;
double change = price * MAX_PRICE_CHANGE
* (Random.nextDouble() * 2.0 - 1.0);
prices[i] = new StockPrice(stocks.get(i), price, change);
}
updateTable(prices);
}
/**
* Update the Price and Change fields all the rows in the stock table.
*
* @param prices Stock data for all rows.
*/
private void updateTable(StockPrice[] prices) {
for (int i = 0; i < prices.length; i++) {
updateTable(prices[i]);
}
// // Display timestamp showing last refresh.
// lastUpdatedLabel.setText("Last update : "
// + DateTimeFormat.getMediumDateTimeFormat().format(new Date()));
}
/**
* Update a single row in the stock table.
*
* @param price Stock data for a single row.
*/
private void updateTable(StockPrice price) {
// Make sure the stock is still in the stock table.
if (!stocks.contains(price.getSymbol())) {
return;
}
int row = stocks.indexOf(price.getSymbol()) + 1;
// Format the data in the Price and Change fields.
String priceText = NumberFormat.getFormat("#,##0.00").format(
price.getPrice());
NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
String changeText = changeFormat.format(price.getChange());
String changePercentText = changeFormat.format(price.getChangePercent());
// Populate the Price and Change fields with new data.
stocksFlexTable.setText(row, 1, priceText);
Label changeWidget = (Label)stocksFlexTable.getWidget(row, 2);
changeWidget.setText(changeText + " (" + changePercentText + "%)");
// Change the color of text in the Change field based on its value.
String changeStyleName = "noChange";
if (price.getChangePercent() < -0.1f) {
changeStyleName = "negativeChange";
}
else if (price.getChangePercent() > 0.1f) {
changeStyleName = "positiveChange";
}
changeWidget.setStyleName(changeStyleName);
}
}
最佳答案
堆栈跟踪中对第 29 行的引用可能表明
private StockWatcherConstants constants =
GWT.create(StockWatcherConstants.class);
StockWatcherConstants
的文本在您的帖子中。
Messages
而不是
Constants
——我不记得看到完全相同的错误,但有一些常见的陷阱。
Module.gwt.xml
设置正确。 您的应用程序应该继承国际化模块。
<inherits name="com.google.gwt.i18n.I18N"/>
<extend-property name="locale" values="de"/>
<!-- <extend-property name="locale" values="en"/> -->
<!-- <extend-property name="locale" values="zh"/> -->
<set-property-fallback name="locale" value="de"/>
String localeCookie = Cookies.getCookie(LocaleInfo.getLocaleCookieName());
if(localeCookie != null) {
setLocale(localeCookie);
}
protected void setLocale(String targetLocale) {
if (LocaleInfo.getCurrentLocale().getLocaleName().equals(targetLocale))
return;
Set<String> availableLocales =
new HashSet<String>(Arrays.asList(LocaleInfo.getAvailableLocaleNames()));
if (! availableLocales.contains(targetLocale))
return;
Cookies.setCookie(LocaleInfo.getLocaleCookieName(), targetLocale,
new Date(new Date().getTime() + COOKIE_LIFETIME));
Window.Location.reload();
}
Module.gwt.xml
中声明了区域设置 cookie。 .
<set-configuration-property name="locale.cookie" value="GWTlocale"/>
Places
,您可以使用第二个 cookie 回到原来的位置。
eventBus.addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() {
@Override
public void onPlaceChange(PlaceChangeEvent event) {
Cookies.setCookie(HISTORY_COOKIE,
historyMapper.getToken(event.getNewPlace()),
new Date(new Date().getTime() + COOKIE_LIFETIME));
}
});
String lastToken = Cookies.getCookie(HISTORY_COOKIE);
Place defaultPlace =
(lastToken != null ? historyMapper.getPlace(lastToken) : Place.NOWHERE);
if (defaultPlace == Place.NOWHERE)
defaultPlace = new BestPlaceToStartYourApplication();
historyHandler.register(placeController, eventBus, defaultPlace);
historyHandler.handleCurrentHistory();
关于gwt - StockWatcher : errors when translating contents to german,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8267735/
我们所有基于文本的文件均采用 UTF-8 或 latin-1 (Windows) 编码。我们使用的唯一“特殊字符”是德语变音符号 ä、ö、ü 和 ß。 由于各种原因(包括历史原因,还有“属性文件不能是
目前,我的应用支持英语和德语 本地化,为此我使用了Localizable.strings .您可以在下面的图片中看到项目设置和 Localizable。 现在我在德语本地化方面遇到了问题。在 iPho
months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktob
我已经使用 Collator 对对象数组进行排序。但我发现它像对待普通字母一样对待重音字母: Aktivierung Änderung Auszahlung Bar 相反,我想要这个 Aktivi
我有一个实用类 TestCracker。它有一个 testInput 方法,该方法接受文本,将请求发送到以该文本作为参数的翻译服务并返回响应 JSON 字符串: public class TestCr
我知道如何使用(简单的)key=function 自定义排序。但是,如果我需要更复杂的 key= 函数,该怎么做。我在整理它时遇到了问题。 这是片段:在第一个示例中,我使用 key=locale.st
我正在关注 internationalization chapter .完成将内容翻译成德语的步骤后,当我尝试在浏览器中加载页面时出现此错误: 11:26:27.142 [ERROR] [stockw
我正在寻找 jquery 验证插件 ( http://bassistance.de/jquery-plugins/jquery-plugin-validation/ ) 的方法,该方法只接受字母,包括
我使用 jQuery DataTables 插件,我的问题是我的德国日期没有正确排序。它具有以下格式:dd.mm.YYYY HH:iih 这是我的代码: JSFIDDLE: https://jsfid
我将 Flyway 4.0 与 SpringBoot 1.3.0.RELEASE 和 MySQL 5.6.27 社区服务器一起使用。 当我使用 MySQL Workbench 检查我的架构时,它具有“
我正在使用一个小的 Javascript/Jquery 函数将一个元素注入(inject)到一些文本中,如果还没有这样的元素的话。 代码如下所示: $(document).ready(function
Apache lucene 中是否有一个选项可以正确排序数字和德语变音符号,这意味着,例如“Ü”应解释为“Ue”,表示排序顺序为 U, Ü, Z 而不是: U, Z, Ü 类似于 lucene 默认值
我正在尝试打开一个文件,其文件名是通过在附加了 Tkinter.StringVar 的 ttk.Entry 中键入而创建的。 如果我尝试通过在另一个文件中输入相同的文件名来再次open()该文件如果我
我需要将日期解析为 11 种不同的语言。到目前为止,只有两个给我带来麻烦:德语和乌克兰语。 package com.example; import java.text.ParseException;
我想在我的应用程序布局中做这样的事情: %title= "#{yield(:sub_title)} - Page Name" 在真实的视野中 - content_for :sub_title do
我们的 WooCommerce 网站有一个自定义注册页面,该页面基于 Business Bloomer 短代码,并为用户的名字添加了一个输入字段。我们的functions.php 中的代码如下所示:
我正在将一些输入流从我的 DVB S2 卡转换为 RTMP。 切换到最近的 avconv 和 x264 后一切正常 :) 我唯一不知道的是,如何选择正确的音频流? 源有时最多有 6 个音轨。 Avco
我想使用正则表达式验证用户发送的名字。我找到了多个名字表达式,但我还想添加德语字符,例如 äöüß 和法语字符 à À è È é É ù Ù ì Ì ò Ò ñ Ñ到它。我尝试了 SO here 建
这里是保罗。我是 JavaScript 的新手,正在尝试构建一个类似于这个问题中描述的闹钟: Why does my alarmclock script stop working? 来自 Whakke
我无法用德语显示以下操作的月份: var date = moment.unix(valueTimestamp).format("DD. MMMM YYYY"); 我已经尝试了以下方法,但它不起作用:
我是一名优秀的程序员,十分优秀!