我试图从eclipse 3.6运行GWT测试,但一直坚持这个奇怪的错误.
在模块'com.company.demo.smartgwt.module'中找不到测试类'com.company.demo.smartgwt.RequestBuilderTest'; 没有看到该类型的编译单元
已经尝试添加源文件夹到运行对话框- >提到的类路径和源标签在这里.没有运气,没有选择..任何建议人?
完整错误堆栈:
com.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.company.demo.smartgwt.RequestBuilderTest' was not found in module 'com.company.demo.smartgwt.module'; no compilation unit for that type was seen
at com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:718)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1317)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1280)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:625)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:456)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:311)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Run Code Online (Sandbox Code Playgroud) 我想在我当前工作的CellTree上触发"打开根节点"事件,该事件现在具有以下行为:
@Override
public <T> NodeInfo<?> getNodeInfo(final T value) {
return new DefaultNodeInfo<Categoria>(
(value instanceof Categoria) ?
createBranchDataProvider((Categoria)value) :
rootDataProvider,
new CategoriaCell()
);
}
private AsyncDataProvider<Categoria> createRootDataProvider() {
AsyncDataProvider<Categoria> dataProvider = new AsyncDataProvider<Categoria>() {
@Override
protected void onRangeChanged(HasData<Categoria> display) {
AsyncCallback<Categoria[]> cb = new AsyncCallback<Categoria[]>() {
@Override
public void onSuccess(Categoria[] result) {
updateRowCount(result.length, true);
updateRowData(0, Arrays.asList(result));
}
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.toString());
}
};
rpcService.getCategorie(cb);
}
};
return dataProvider;
}
Run Code Online (Sandbox Code Playgroud)
如何触发"onRangeChanged"事件,刷新我的1级节点?
我的便利方法缺失了什么?
private void updateTree() {
TreeNode rootTreeNode = …Run Code Online (Sandbox Code Playgroud) 好的伙计们,我已经解决了这个问题大约两个星期了,现在尝试我能想到的一切,并在这里看到大量的答案,感觉他们会回答它,但我只是无法弄清楚我的意思是做我正在尝试做的事情,这让我绝对坚持!似乎没有人在任何地方找到答案,到处都有一半的答案,但似乎没有人真正做我需要它做的事情,当然有人已经解决了这个问题!请原谅真正长的问题,但重要的是问题是正确的,所以答案实际上满足了需要!:d
如果您可能提供任何不考虑我的数据存储区/服务器是Google App Engine(GAE),而我的客户端是用Google Web Toolkit(GWT)编写的答案,请不要再费心阅读了.是用Java编写的,我对Python或MySQL或PHP或类似的东西都不了解
最后,如果有人知道一个更好的地方来计算这样的东西,请告诉我,因为我不断提出这样的问题,不知道如何找到除此之外的解决方案,或花费数小时搜索谷歌对于已经设法解决的其他人.我也不明白如何从JavaDocs中找出任何东西 - 抱歉,但是直到有人向我解释,我才不会得到它
我有一个存储在服务器上的日期时间(显然是UTC)我还在服务器上存储了一个存储为字符串的每个业务所有者的TimeZone(例如"America/New_York").这个字符串是通过java.util.TimeZone.getAvailableIDs()在服务器上使用并让业务所有者为他们的业务选择相关时区获得的(默认是"Europe/London"如果他们没有选择任何东西 - 不需要挂断那个位)我需要传递任何日期时间在未来的某个时间点到客户端PC,在他们的PC上忽略本地时区,因为日期时间需要根据业务所有者的时区显示.
举例来说,企业主是伦敦的理发师,他们有在线预约时间表,任何潜在客户都可以查看.其中一位客户(也在伦敦)想预约,在9月3日星期一上午9点看到一个位置并预订.
然后将其作为UTC时间(实际上是0800,因为BST是UTC + 1)存储在数据存储区中,当然业务所有者已选择"Europe/London"作为其时区.到目前为止一切都很好.
现在,在未来的某个时刻,客户正在纽约举行商务会议,并意识到他们在接下来的一周预约在伦敦理发,他们希望将其移动一周,所以他们接着尝试查看预约(在美发师预约簿中),但他们不希望将其视为纽约时间凌晨4点,他们希望将其视为英国时间早上9点.
所以我的问题是,当客户在9月3日点击VIEW约会时,服务器可以发回UTC日期时间0800和java.util.TimeZoneID字符串"Europe/London"
但因为在客户端我只能使用
com.google.gwt.i18n.client.TimeZone
Run Code Online (Sandbox Code Playgroud)
它不允许我使用该功能
TimeZone bizTimeZone=TimeZone.getTimeZone("Europe/London")
(which works for `java.util.TimeZone`)
Run Code Online (Sandbox Code Playgroud)
因为它会导致错误
"The method getTimeZone(String) is undefined for the type TimeZone"
Run Code Online (Sandbox Code Playgroud)
它建议改变它
com.google.gwt.i18n.client.TimeZone.createTimeZone("Europe/London")
Run Code Online (Sandbox Code Playgroud)
但是这个版本,期待一个GWT com.google.gwt.i18n.client.TimeZoneConstants"对象"(示例显示在此消息的末尾)而不是java.util.TimeZone.createTimeZone()将接受的简单字符串.
我可以使用以下方法创建:
final TimeZoneConstants constTz = GWT.create(TimeZoneConstants.class);
final TimeZone timeZoneCali = TimeZone.createTimeZone(constTz.europeLondon());
Run Code Online (Sandbox Code Playgroud)
但是当我开始使用"Europe/London"和/或我不知道如何将此对象存储到App Engine数据库中然后稍后检索它时,我不知道该怎么做.
顺便提一下,在评论文本中我也尝试使用以下几行:
//Calendar tmad = new GregorianCalendar(TimeZone.getTimeZone("Europe/London"));
//Calendar cal = Calendar.getInstance(someTimeZone); …Run Code Online (Sandbox Code Playgroud) 在GWT中序列化BigDecimal的首选方法是什么?
有没有聪明的解决方法,或者你只是使用Double或String?
在所有GWT痛苦中,这是迄今为止最大的痛苦; 我讨厌创建两个模型,一个用于服务器,一个用于GWT,并将数据从一个转换为另一个.另一方面,虽然我不太关心使用String而不是javax.xml.datatype.Duration,但由于计算,我必须在服务器上使用BigDecimal,这意味着两个模型和转换,或者每次计算都需要大量的BigDecimal转换.
有没有办法通过从数据存储区加载的数据生成的GWT UI元素来加速页面的填充?加载页面时,我可以避免进行不必要的RPC调用吗?
有关我遇到的问题的更多详细信息:有一个页面,我在其中生成一个表,其中包含从数据存储区加载的实体列表的名称和按钮.页面有一个EntryPoint,在它的onModuleLoad()中我做了这样的事情:
final FlexTable table = new FlexTable();
rpcAsyncService.getAllCandidates(new AsyncCallback<List<Candidate>>() {
public void onSuccess(List<Candidate> candidates) {
int row = 0;
for (Candidate person : candidates) {
table.setText(row, 0, person.getName());
table.setWidget(row, 1, new ToggleButton("Yes"));
table.setWidget(row, 2, new ToggleButton("No"));
row++;
}
}
...
});
Run Code Online (Sandbox Code Playgroud)
这可以工作,但是需要超过30秒来加载具有300个候选按钮的页面.这是无法接受的.
该应用正在Google App Engine上运行并使用应用引擎的数据存储区.
我使用以下代码作为GWT-RPC的GWT服务器端类(servlet)的一部分.
private void getImage() {
HttpServletResponse res = this.getThreadLocalResponse();
try {
// Set content type
res.setContentType("image/png");
// Set content size
File file = new File("C:\\Documents and Settings\\User\\image.png");
res.setContentLength((int) file.length());
// Open the file and output streams
FileInputStream in = new FileInputStream(file);
OutputStream out = res.getOutputStream();
// Copy the contents of the file to the output stream
byte[] buf = new byte[1024];
int count = 0;
while ((count = in.read(buf)) >= 0) {
out.write(buf, 0, count);
}
in.close();
out.close();
} catch …Run Code Online (Sandbox Code Playgroud) 如果我有JBoss Errai(我为了服务器推送而下载),使用GWT-RPC进行客户端调用还有什么好处吗?或者如果我只是使用Errai调用一切,客户端和服务器端,我会失去什么?它可以发送所有相同的数据类型,并且它也可以像GWT-RPC一样用于客户端发起的调用吗?
我的GWT项目工作正常,但今天,经过一些更改并添加新的一个异步调用没有执行.例外情况是"此应用程序已过期,请单击浏览器上的刷新按钮".执行所有其他异步调用.
An IncompatibleRemoteServiceException was thrown while processing this call.
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: This application is out of date, please click the refresh button on your browser. ( Blocked attempt to access interface 'com.client.FInterface', which is not implemented by 'com.server.FServiceImpl'; this is either misconfiguration or a hack attempt )
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:252)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:206)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
Run Code Online (Sandbox Code Playgroud)
客户:
public void onClick(ClickEvent event) {
fService.getRepositories(repocallback);
}
});
Run Code Online (Sandbox Code Playgroud)
接口
@RemoteServiceRelativePath("init")
public interface FInterface extends RemoteService{
FCollection getRepositories();
}
Run Code Online (Sandbox Code Playgroud)
AsyncInterface
public interface FInterfaceAsync {
void getRepositories(AsyncCallback<FCollection> repositoryCallback);
} …Run Code Online (Sandbox Code Playgroud) 我正在拨打GWT的服务电话.
在客户端,我只对该方法进行了一次调用,但在服务器端,服务中的方法被调用两次.
我用Firefox中的GWT-Tools调试了客户端; 当我调用一次方法时,服务器中有两次执行.参数中的数据相同,但是在两个不同的线程中.
我在相同的应用程序中有更多的调用,但问题只出在那个问题上.
在我的GWT应用程序中,使用许多不同的服务对服务器进行了许多不同的异步调用.为了做更好的错误处理,我想包装所有的回调,以便我可以像InvocationExceptions在一个地方一样处理异常.超类实现AsyncCallback实际上不是一个选项,因为这意味着我将不得不修改每个异步调用.
RpcServiceProxy#doCreateRequestCallback()看起来像要覆盖的方法.很简单.我只是看不出如何让GWT使用我的新课程.
陈述问题的另一种方式是
如何让GWT使用我自己的子类
RpcServiceProxy?