Sorry about this long question.
I do experience some difficulties playing with GWT RF. ( keywords: Gwt ,Hibernate, Valueproxy, Locator, ServiceLayerDecorator)
i am beginner level.
Will try to be as accurate as possible but i probably may have misunderstood a couple of things and some typo errors can appear because code is simplified.
In brief, when RF is trying to send datas back to the client, i 've got an error.
com.google.web.bindery.requestfactory.server.UnexpectedException: The domain type com.test.persistance.entites.base.BaseTest cannot be sent to the client
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.die(ServiceLayerDecorator.java:216)
at com.google.web.bindery.requestfactory.server.ResolverServiceLayer.resolveClientType(ResolverServiceLayer.java:91)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveClientType(ServiceLayerDecorator.java:142)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveClientType(ServiceLayerDecorator.java:142)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveClientType(ServiceLayerDecorator.java:142)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.resolveClientType(ServiceLayerDecorator.java:142)
at com.test.server.MyDecorator.resolveClientType(MyDecorator.java:22
Call is made by
requestFactory.createMvtRequest()
.findAllMvts()
.fire(rec);
Receiver used ( extract )
In details :Receiver<List<MvtProxy>> rec = new Receiver<List<MvtProxy>>()
{ public void onSuccess (List<MvtProxy> mvts) ....
Client Side
- Widget
- Factory @Service(value = MvtService.class, locator = MvtServiceLocator.class)
- MvtProxy as ValueProxy( @ProxyFor(value = Test.class, locator = MvtLocator.class)
- Test ( public class Test extends BaseTest )
- BaseTest ( public class BaseTest implements Serializable )
- MvtService (public class MvtService)
- MvtServiceLocator (public class MvtServiceLocator implements ServiceLocator)
- CEMMvt (public class CEMMvt)
- MyDecorator (public class MyDecorator extends ServiceLayerDecorator)
- MyRequestFactoryServlet (public class MyRequestFactoryServlet extends RequestFactoryServlet) Replacing RFServlet in web.xml
CEMMvt list() method is using a DAO to get the datas from a database and returning a List<Test>. It is well populated.
I previously had the same error "com.google.web.bindery.requestfactory.server.UnexpectedException: The domain type com.test.persistance.entites.Test cannot be sent to the client"
Seems to be resolved by using MyDecorator but whats am i doing wrong in this particular case ?
Many thanks for pointing me in the right direction.
Regards,
pierre
MyRequestFactoryServlet :
import com.google.web.bindery.requestfactory.server.DefaultExceptionHandler;
import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;
public class MyRequestFactoryServlet extends RequestFactoryServlet
{
public MyRequestFactoryServlet() {
super(new DefaultExceptionHandler(), new MyDecorator());
}
}
MyDecorator
import com.google.web.bindery.requestfactory.server.ServiceLayerDecorator;
import com.google.web.bindery.requestfactory.shared.Locator;
public class MyDecorator extends ServiceLayerDecorator {
@Override
public Class<? extends Locator<?, ?>> resolveLocator(Class<?>
domainType) {
if(domainType.getName().contains("Test"))
return super.resolveLocator(domainType.getSuperclass());
return super.resolveLocator(domainType);
}
@Override
public <T> Class<? extends T> resolveClientType(Class<?> domainClass,
Class<T> clientType, boolean required) {
if(domainClass.getName().contains("Test"))
return super.resolveClientType(domainClass.getSuperclass(),clientType, required);
return super.resolveClientType(domainClass, clientType,required);
}
}
CEMMvt
public static List<Test> list () {
if (mvtsDAO == null) {
HttpServletRequest request = RequestFactoryServlet.getThreadLocalRequest();
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
mvtsDAO =context.getBean(IMvtEnteteDAO.class);
}
try {
List<?> tempList = new ArrayList<Test>();
Map<String, Object> map = new HashMap<String, Object>();
map.put(Test.PROP_REF_RECEP, "EXAMPLE");
List<Test> liste = mvtsDAO.loadAllTest(map);
return liste;
} catch (PersistanceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
Test
public class Test extends BaseTest {
private static final long serialVersionUID = 1L;
public Test () {
super();
}
public Test (Long id) {
super(id);
}
}
BaseTest
import java.io.Serializable;
public class BaseTest implements Serializable {
public static String PROP_ID = "id";
public static String PROP_REF_RECEP = "ref_recep";
// Fields
private Long id;
private String refRecep;
// Constructors
/** default constructor */
public BaseTest() {
}
/** minimal constructor */
public BaseTest(Long id) {
this.id = id;
}
/** full constructor */
public BaseTest(Long id, String refRecep) {
this.id = id;
this.refRecep = refRecep;
}
// Property accessors
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getRefRecep() {
return this.refRecep;
}
public void setRefRecep(String refRecep) {
this.refRecep = refRecep;
}
}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment