如何从GWT编辑器类访问底层POJO
我的POJO中有一个HashMap,我正在使用GWT中的编辑器框架进行编辑。虽然我可以访问通过getter/setter绑定的标准成员变量,但我不知道如何访问HashMap中的值。如何通过使用SimpleBaneditorDriver的编辑器访问正在编辑的底层POJO 我的POJO:如何从GWT编辑器类访问底层POJO,gwt,gwt-editors,Gwt,Gwt Editors,我的POJO中有一个HashMap,我正在使用GWT中的编辑器框架进行编辑。虽然我可以访问通过getter/setter绑定的标准成员变量,但我不知道如何访问HashMap中的值。如何通过使用SimpleBaneditorDriver的编辑器访问正在编辑的底层POJO 我的POJO: @Entity(noClassnameStored=true) public class ProfileConfig extends BaseEntity { @Indexed(unique=true)
@Entity(noClassnameStored=true)
public class ProfileConfig extends BaseEntity {
@Indexed(unique=true)
private String name;
private boolean isDefault;
private HashMap<ProfileID, ProfileInfo> profiles= new HashMap<ProfileID, ProfileInfo>();
public ProfileInfo getProfile(ProfileID id) {
return profiles.get(id);
}
public void setProfile(ProfileID id, ProfileInfo p) {
profiles.put(id, p);
}
@实体(noClassnameStored=true)
公共类ProfileConfig扩展了BaseEntity{
@索引(唯一=真)
私有字符串名称;
私有布尔值是默认值;
私有HashMap profiles=newhashmap();
公共配置文件信息获取配置文件(配置文件id){
返回profiles.get(id);
}
public void setProfile(ProfileID,ProfileInfo-p){
配置文件。放置(id,p);
}
我的编辑:
public class ProfileConfigEditor extends Composite implements ManagedObjectEditor<ProfileConfig> {
private static ProfileConfigEditorUiBinder uiBinder = GWT.create(ProfileConfigEditorUiBinder.class);
interface ProfileConfigEditorUiBinder extends UiBinder<Widget, ProfileConfigEditor> {
}
private UserManager userManager;
@UiField
CellList Profiles;
@UiField
TextBox name;
@UiField
CheckBox isDefault;
公共类ProfileConfigEditor扩展复合实现ManagedObjectEditor{
私有静态ProfileConfigEditorUiBinder uiBinder=GWT.create(ProfileConfigEditorUiBinder.class);
接口配置文件ConfigEditorUIBinder扩展了UiBinder{
}
私有用户管理器用户管理器;
@尤菲尔德
细胞列表资料;
@尤菲尔德
文本框名称;
@尤菲尔德
复选框为默认值;
因此,假设我有一个来自userManager的有效配置文件ID列表,那么如何从我的编辑器中从POJO调用getProfile方法呢?您需要的是一个
ValueAwareEditor
public class ProfileConfigEditor extends Composite implements ManagedObjectEditor<ProfileConfig>, ValueAwareEditor<ProfileConfig> {
void setValue(ProfileConfig value){
// TODO: Call ProfileConfig.getProfile()
}
void flush(){
// TODO: Call ProfileConfig.setProfile()
}
// ... Other methods here
公共类ProfileConfigEditor扩展了组合实现ManagedObjectEditor、ValueAwareEditor{
void setValue(ProfileConfig值){
//TODO:调用ProfileConfig.getProfile()
}
无效刷新(){
//TODO:调用ProfileConfig.setProfile()
}
//……这里还有其他方法
或者,如果您想要更多的挑战,您可以查看自己的复合编辑器
,例如查看ListEditor的源代码。在您的情况下,您可以实现一个复合编辑器
。您可以将其作为此编辑器将获取一个ProfileConfig
对象,提取一个或多个ProfileInfo
对象,并使用一个或多个MyNewProfileInfoEditor
编辑器对其进行编辑