在RPC调用(GWT)期间丢失POJO信息
我在RPC调用和GWT方面有问题。本质上,我有一个在RPC调用(GWT)期间丢失POJO信息,gwt,Gwt,我在RPC调用和GWT方面有问题。本质上,我有一个Person类(客户端和服务器之间的公共代码),该类在客户端web代码中创建,通过RPC调用发送到服务器代码,然后保存到DB(OrientDB)。我已核实以下工作: RPC调用-我能够向服务器发送信息并从服务器检索信息 保存到数据库-已验证Person对象是否保存到数据库 我遇到的问题是将POJO从客户端传输到服务器。我已经验证了POJO的属性在发送到服务器之前是完整的,但是,传递到服务器的对象包含所有属性的空值。本质上,类是被传输的,但信息不是
Person
类(客户端和服务器之间的公共代码),该类在客户端web代码中创建,通过RPC调用发送到服务器代码,然后保存到DB(OrientDB)。我已核实以下工作:
Person
对象,后跟从中继承的抽象类:
服务
ServiceAsync
最后,电话本身
private static void savePerson(Person p)
{
// Initialize the service proxy.
if (peopleSvc == null) {
peopleSvc = GWT.create(PeopleService.class);
}
//resets status
st="";
// Set up the callback object.
AsyncCallback<String> callback = new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
st = caught.getMessage();
Label stLabel= new Label(st);
personTable.setWidget(3,1,stLabel);
}
@Override
public void onSuccess(String result) {
st = result;
HTML stLabel= new HTML(st);
joinPanel.add(stLabel);
}
};
// Make the call to the people service.
peopleSvc.savePerson(p, callback);
}
private static void savePerson(个人p)
{
//初始化服务代理。
if(peopleSvc==null){
peopleSvc=GWT.create(PeopleService.class);
}
//重置状态
st=”“;
//设置回调对象。
AsyncCallback callback=新的AsyncCallback(){
@凌驾
失败时的公共无效(可丢弃){
st=catch.getMessage();
标签stLabel=新标签(st);
setWidget(3,1,stLabel);
}
@凌驾
成功时的公共void(字符串结果){
st=结果;
HTML stLabel=新的HTML(st);
joinPanel.add(stLabel);
}
};
//打电话给人民服务部。
peopleSvc.savePerson(p,回调);
}
我通过实现GWT的IsSerializable接口解决了这个问题。我还从Person类中删除了Serializable接口,并让它从其继承的抽象类继承IsSerializable。我通过实现GWT的IsSerializable接口解决了这个问题。我还从Person类中删除了Serializable接口,并让它从其继承的抽象类中继承IsSerializable。是否可以通过向pojo添加默认构造函数重试?忽略上述注释。我误读了班上的人物。我也删除了答案中的引用。您可以通过向pojo添加默认构造函数重试吗?忽略上面的注释。我误读了班上的人物。我也删除了答案中的参考。
package org.matesweb.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import org.matesweb.shared.Person;
@RemoteServiceRelativePath("peopleService")
public interface PeopleService extends RemoteService {
//test services
String stringTest(String outgoingString);
Person getPerson(String persId);
//production services
String savePerson(Person p);
}
import com.google.gwt.user.client.rpc.AsyncCallback;
import org.matesweb.shared.Person;
public interface PeopleServiceAsync
{
//tests
void stringTest(String outgoingString, AsyncCallback<String> incomingString);
void getPerson(String persId, AsyncCallback<Person> retPerson);
//production services
void savePerson(Person p , AsyncCallback<String> st);
}
//production calls
@Override
public String savePerson(Person p) {
String st = ioObj.saveObj(p);
if(st.equals("Success")){
return "Your information has been saved successfully!";
} else{
return "Something has gone wrong on our end... Sorry! Error:<br /> " + st;
}
}
private static void savePerson(Person p)
{
// Initialize the service proxy.
if (peopleSvc == null) {
peopleSvc = GWT.create(PeopleService.class);
}
//resets status
st="";
// Set up the callback object.
AsyncCallback<String> callback = new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
st = caught.getMessage();
Label stLabel= new Label(st);
personTable.setWidget(3,1,stLabel);
}
@Override
public void onSuccess(String result) {
st = result;
HTML stLabel= new HTML(st);
joinPanel.add(stLabel);
}
};
// Make the call to the people service.
peopleSvc.savePerson(p, callback);
}