- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试研究如何使用 GWT RPC 将域对象从服务器端发送到客户端。我已经编写了一个非常简单的用例,它代表了我(和其他人?)需要能够做但目前无法开始工作的那种事情。
我已经搜索了文档、教程和论坛,但它们要么显示字符串被传递,要么提供解释(当我将它们应用于此时)仍然不起作用。
希望有人可以向我和其他人解释为什么此代码不起作用以及如何使其工作。
谢谢你。
以下是错误消息。
13:12:54.328 [DEBUG] [org.redboffin.worldhug.Test] Validating newly compiled units
13:12:54.328 [ERROR] [org.redboffin.worldhug.Test] Errors in 'file:/C:/Documents%20and%20Settings/Darren/workspace/WorldHug/src/org/redboffin/worldhug/client/test/TestService.java'
13:12:54.343 [ERROR] [org.redboffin.worldhug.Test] Line 14: No source code is available for type org.redboffin.worldhug.server.test.TestObject; did you forget to inherit a required module?
13:12:54.515 [ERROR] [org.redboffin.worldhug.Test] Errors in 'file:/C:/Documents%20and%20Settings/Darren/workspace/WorldHug/src/org/redboffin/worldhug/client/test/TestServiceAsync.java'
13:12:54.515 [ERROR] [org.redboffin.worldhug.Test] Line 12: No source code is available for type org.redboffin.worldhug.server.test.TestObject; did you forget to inherit a required module?
13:12:55.953 [ERROR] [org.redboffin.worldhug.Test] Errors in 'file:/C:/Documents%20and%20Settings/Darren/workspace/WorldHug/src/org/redboffin/worldhug/client/test/TestView.java'
13:12:55.968 [ERROR] [org.redboffin.worldhug.Test] Line 42: No source code is available for type org.redboffin.worldhug.server.test.TestObject; did you forget to inherit a required module?
13:12:55.968 [ERROR] [org.redboffin.worldhug.Test] Line 46: No source code is available for type org.redboffin.worldhug.server.test.InnerObject; did you forget to inherit a required module?
13:12:55.984 [ERROR] [org.redboffin.worldhug.Test] Line 48: No source code is available for type org.redboffin.worldhug.server.test.ListObject; did you forget to inherit a required module?
13:12:56.765 [INFO] [org.redboffin.worldhug.Test] Module org.redboffin.worldhug.Test has been loaded
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.user.User" />
<source path="client/test" />
<entry-point class="org.redboffin.worldhug.client.test.Test"></entry-point>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>org.redboffin.worldhug.server.test.TestServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/worldhug/test/testService</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>test.html</welcome-file>
</welcome-file-list>
</web-app>
package org.redboffin.worldhug.server.test;
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.user.client.rpc.IsSerializable;
public class TestObject implements IsSerializable {
private String testObjectString;
private InnerObject innerObject;
private List<ListObject> listObjects = new ArrayList<ListObject>();
public TestObject() {}
// Getters and setters removed for brevity
}
package org.redboffin.worldhug.server.test;
import com.google.gwt.user.client.rpc.IsSerializable;
public class InnerObject implements IsSerializable {
private String innerObjectString;
public InnerObject() {}
// Getters and setters removed for brevity
}
package org.redboffin.worldhug.server.test;
import com.google.gwt.user.client.rpc.IsSerializable;
public class ListObject implements IsSerializable {
private String listObjectString;
public ListObject() {}
// Getters and setters removed for brevity.
}
package org.redboffin.worldhug.client.test;
import org.redboffin.worldhug.server.test.TestObject;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the Test Service.
* @author Darren
*/
@RemoteServiceRelativePath("testService")
public interface TestService extends RemoteService {
TestObject test();
}
package org.redboffin.worldhug.client.test;
import org.redboffin.worldhug.server.test.TestObject;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The async counterpart of <code>TestService</code>.
* @author Darren
*/
public interface TestServiceAsync {
void test(AsyncCallback<TestObject> callback);
}
package org.redboffin.worldhug.server.test;
import java.util.List;
import org.redboffin.worldhug.client.test.TestService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
* @author Darren
*/
@SuppressWarnings("serial")
public class TestServiceImpl extends RemoteServiceServlet implements TestService {
@Override
public TestObject test() {
TestObject testObject = new TestObject();
testObject.setTestObjectString("Test Object String");
InnerObject innerObject = new InnerObject();
innerObject.setInnerObjectString("Inner Object String");
testObject.setInnerObject(innerObject);
List<ListObject> listObjects = testObject.getListObjects();
ListObject listObjectOne = new ListObject();
listObjectOne.setListObjectString("List Object One");
listObjects.add(0, listObjectOne);
ListObject listObjectTwo = new ListObject();
listObjectTwo.setListObjectString("List Object Two");
listObjects.add(0, listObjectTwo);
ListObject listObjectThree = new ListObject();
listObjectThree.setListObjectString("List Object Three");
listObjects.add(0, listObjectThree);
return testObject;
}
}
package org.redboffin.worldhug.client.test;
import java.util.ArrayList;
import java.util.Iterator;
import org.redboffin.worldhug.server.test.InnerObject;
import org.redboffin.worldhug.server.test.ListObject;
import org.redboffin.worldhug.server.test.TestObject;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
public class TestView extends Composite {
private static TestViewUiBinder uiBinder = GWT.create(TestViewUiBinder.class);
interface TestViewUiBinder extends UiBinder<VerticalPanel, TestView> {}
@UiField Label testObjectStringLabel;
@UiField Label innerObjectStringLabel;
@UiField VerticalPanel listObjectsPanel;
@UiField Button button;
@UiField Label errorMessageLabel;
public TestView(String firstName) {
initWidget(uiBinder.createAndBindUi(this));
}
@UiHandler("button")
void onClick(ClickEvent e) {
TestServiceAsync testService = (TestServiceAsync) GWT.create(TestService.class);
AsyncCallback<TestObject> callback = new AsyncCallback<TestObject>() {
public void onSuccess(TestObject testObject) {
testObjectStringLabel.setText(testObject.getTestObjectString());
InnerObject innerObject = testObject.getInnerObject();
innerObjectStringLabel.setText(innerObject.getInnerObjectString());
ArrayList<ListObject> listObjects = (ArrayList<ListObject>) testObject.getListObjects();
Iterator<ListObject> iterator = listObjects.iterator();
while(iterator.hasNext()) {
ListObject listObject = (ListObject) iterator.next();
listObjectsPanel.add(new Label(listObject.getListObjectString()));
}
}
public void onFailure(Throwable caught) {
errorMessageLabel.setText("Error : "+caught.getMessage());
}
};
testService.test(callback);
}
}
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder
xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:VerticalPanel>
<g:Label>Test Object</g:Label>
<g:Label ui:field="testObjectStringLabel"></g:Label>
<g:VerticalPanel>
<g:Label>Inner Object</g:Label>
<g:Label ui:field="innerObjectStringLabel"></g:Label>
</g:VerticalPanel>
<g:VerticalPanel ui:field="listObjectsPanel">
<g:Label>List Objects</g:Label>
</g:VerticalPanel>
<g:Button ui:field="button">Display Test Object</g:Button>
<g:Label ui:field="errorMessageLabel"></g:Label>
</g:VerticalPanel>
</ui:UiBinder>
最佳答案
您需要标识包含要进行 GWT 编译的源代码的所有包。
例如
<source path="client/test"/>
<source path="server/test"/>
<source path="client"/>
<source path="shared"/>
关于GWT 简单 RPC 用例问题 : Code included,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2237142/
RPC 在消息传递方面的缺点是什么? 最佳答案 您是在谈论 RPC 与消息传递吗?就像(通常)异步消息传递一样?如果这就是您所说的,那么消息传递往往会以复杂性和额外基础架构为代价变得更加健壮。 最简单
我想查看不在我钱包中的btc地址余额。似乎像 blockchainexplorer 这样的网站会做这类事情。他们还提供 API,但我遇到了他们的 API 使用限制。所以我下载了完整的区 block 链
我想获得这样的 RPC 信息: > show route output interface ae40.4181 | display xml rpc
我从我的 javascript 发送交易 Metamask 打开传输对话框 我确定 i get an error message in metamask (inpage.js:1 MetaMask -
有一个场景,客户端通过 RPC 触发 cordapp 并等待结果。 rpcConnection.proxy .startFlow(::ImportAssetFlow, importDto) .retu
super 简单的问题,我在那里找不到具体的答案。 RabbitMQ 在处理 HTTP 请求时是否适合做类似 RPC 的操作? 我有兴趣在收到用户 HTTP 请求时触发一条消息,等待来自后端服务器的响
在为我的网站编写 pingback 处理程序的过程中,我注意到 XML-RPC specification没有说明应该定义什么故障代码及其含义。所以问题是,是否有一个普遍接受的故障代码标准来指定这些信
我正在尝试创建一个可以演示 Telegram API 某些功能的小程序。我希望能够通过 SMS 注册和验证用户。根据user authorization guide ,我需要调用 auth.sendC
我将实现 JSON-RPC Web 服务。我需要这方面的规范。到目前为止,我只找到了一种可以称为真正规范的资源: JSON-RPC 1.0 http://json-rpc.org/wiki/speci
我需要学习Apache Thrift一个大学项目。这样tutorial说,它是一个 RPC 框架,也是我能找到的除 their documentation 之外的 Thrift 的唯一文档。 . 有人
我有一个多服务器多客户端应用程序,我想保留一些由单个守护进程管理的公共(public)数据(以避免并发的噩梦),这样服务器就可以在需要操作共享数据时询问它。 我已经在服务器中使用 libevent,所
我在我的代码中做了一个rpc。在成功方面,我有一些代码作为此 rpc 调用的触发器。 我的代码中有第二个 rpc。在另一个调用的成功端,我想执行第一个 rpc 成功端中的代码。 在不复制第一个rpc
我有一个奇怪的问题(希望您能提供帮助):我正在开发一个 GWT Web 应用程序,该应用程序有时会同时进行超过 4 - 5 个 GWT RPC 调用 - 就时间而言。 每隔一段时间 - 每 15 个电
我遇到了将大型 RPC 服务拆分成较小块的问题。我在这里找到了基础知识 GWT RPC - Multiple RPC Services Per App ,但我正在努力实现。我在任何地方都找不到任何好的
我目前正在使用具有一项大型 RPC 服务的 GWT 应用程序。它有 100 多个方法,所有方法都做不同的事情。如果将其拆分为多个 RPC 服务,我会获得什么样的性能优势/障碍?我相信我必须为每个人制作
有谁知道可以将 RPC/编码 WSDL 转换为 RPC/文字的工具或“黑盒”?我没有能力更改 API(这不是我的)但我想使用的工具不支持 RPC/Encoded。我想看看是否有人创建了一个简单的黑盒通
我正在调查使用 gorilla web toolkit创建一个简单的 RPC API。我正在使用他们文档中的示例,并且正在使用 Advanced Rest Client 进行测试在 Chrome 中使
由于 JSON-RPC 是面向过程的,因此我在 C# 中有一个 API 不会映射到 JSON-RPC。您将如何在 JSON-RPC 中表示面向对象的 API? 我当然可以使用 JSON-RPC 扩展,
我是来自意大利的计算机科学专业的学生,我必须做一个基于 的项目修改 Daemontools Of D.J. 的版本Bernstein 必须在 Unix 下实现远程过程调用。 通常,为了使用工具启动
我正在将 gwt 与 gwt-platform 结合使用,并使用调度异步进行服务器调用。我遇到的问题是我正在使用的操作没有被标记为可序列化或添加到 *.gwt.rpc 文件中。当我的代码运行时,我得到
我是一名优秀的程序员,十分优秀!