2012-04-08 2 views
3

GWTのエディタフレームワークを使用して編集しているPOJO内にHashMapがあります。私はgetter/setterを通してバインドされた標準メンバー変数にアクセスできますが、HashMap内の値にアクセスする方法はわかりません。 SimpleBeanEditorDriverを使用しているエディタで編集中のPOJOにアクセスするにはどうすればよいですか?GWTエディタクラスから基になるPOJOにアクセスする方法

マイPOJO:

@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); 
    } 

マイエディタ:

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; 

は、だから私はのUserManagerから有効なプロファイルIDのリストを持っていることを考えると、どのように私は私からはGetProfileメソッドを呼び出して行くのです私のエディタ内のPOJO?

答えて

2

必要なものは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 

、あなたは、CompositeEditorあなた自身の圧延を見て、たとえばListEditorのソースコードを見ることができます。あなたの場合、CompositeEditor<ProfileConfig, ProfileInfo, MyNewProfileInfoEditor>を実装します。これは「このエディタはProfileConfigオブジェクトを受け取り、1つ以上のProfileInfoオブジェクトを抽出し、1つ以上のMyNewProfileInfoEditorエディタで編集します」

関連する問題