简体   繁体   English

将Gilead与GXT和休眠一起使用的最佳方法是什么?

[英]What is the best way to use Gilead with GXT and hibernate?

I wanted to understand the best way to integrate Gilead with GXT and hibernate. 我想了解将Gilead与GXT和hibernate集成的最佳方法。 This article http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html describes the usage of Gilead with GWT. 本文http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html描述了Gilead与GWT的结合使用。

Most of the GXT components are bound using custom classes that inherit BaseModelData, does this mean we need to convert the bean that is persisted (LightEntity bean) to the custom class that extends BaseModelData before binding to the GXT compoenent. 大多数GXT组件是使用继承BaseModelData的自定义类进行绑定的,这是否意味着我们需要在绑定到GXT组件之前将持久化的bean(LightEntity bean)转换为扩展BaseModelData的自定义类。 Is my understanding correct ? 我的理解是否正确? If yes, what is the advantage I get by doing this, I would need to use dozer/hand code conversion yet again ? 如果是,这样做有什么好处,我将需要再次使用推土机/手动代码转换吗?

The examples on the gilead site as pathetic, can anyone provide a link where a complete example of using GXT with Gilead and hibernate is present ? 吉利德网站上的示例可悲,任何人都可以提供一个链接,其中提供了将GXT与吉利德和休眠一起使用的完整示例吗?

Thanks 谢谢

You do not need to have your DAOs implement BaseModelData. 您无需让DAO实现BaseModelData。

What you have to do is for each DAO class you create an interface in your GWT client package. 您需要为每个DAO类在GWT客户端包中创建一个接口。 You have to extend BeanModelMarker and use the @BEAN annotation. 您必须扩展BeanModelMarker并使用@BEAN批注。 This tells EXT GWT that your DAO can be used as a BeanModel 这告诉EXT GWT您的DAO可以用作BeanModel

package org.gwtapp.client.model;

import com.extjs.gxt.ui.client.data.BeanModelMarker;
import com.extjs.gxt.ui.client.data.BeanModelMarker.BEAN;

@BEAN(org.vnsny.domain.MyClass.class)
public interface MyClassBeanModel extends BeanModelMarker {

}

Then when you need to create a BeanModel from your class you use the BeanModelFactory 然后,当您需要从您的类创建BeanModel时,请使用BeanModelFactory

BeanModel model = BeanModelLookup.get().getFactory(
                MyClass.class).createModel(myClassObj);

Also when you are using data components and retrieving a collection typed as a superclass with subclasses instances you will need to add this setting to the bean reader 另外,当您使用数据组件并检索带有子类实例的超类类型的集合时,您将需要将此设置添加到Bean Reader中

                    reader.setFactoryForEachBean(true);

If you don't set a factory for each bean, the reader will try to cast all objects as the class of the first instance of the collection 如果您没有为每个bean设置工厂,那么读者将尝试将所有对象强制转换为集合的第一个实例的类。

Ex: Super class = Animal SubClasses = Dog, Cat 例如:超类=动物子类=狗,猫

In the remote method you return a list of Animal: List and create the bean model interface for each class. 在远程方法中,您返回动物列表:List并为每个类创建bean模型接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM