2

我在我的项目中实现了一个选择列表。

选项列表文档

我试图改变这个视图的逻辑以适应我的行为。我想将 SourceList 保持原样,并且仅在给定 itemScope 不在 targetList 中时才更改 targetList。

我的做法:

public void onTransfer(TransferEvent event) {

    // wenn wir eine Sprache aktivieren möchten, sollte die sprache nicht
    // aus der source entfernt werden
    if (event.isAdd()) {
        List<String> itemsInScope = (List<String>) event.getItems();
        itemsInScope.addAll(languages.getSource());
        languages.setSource(itemsInScope);

        for(String s : languages.getSource())
            System.out.println(s);
    }


    settingsObject.setActiveLanguages(languages.getTarget());
    settingsObject.setSupportedLanguages(languages.getSource());

    TranslationConfig conf1 = new TranslationConfigManager().getSettings();

    conf1.setActiveLanguages(languages.getTarget());
    conf1.setSupportedLanguages(languages.getSource());

    new TranslationConfigManager().updateSetting(conf1);
}

这在逻辑上适用于 DualList,因为它返回正确的填充列表,但它有点解决方法和肮脏。这里的问题是它仍然删除了视图中的项目。

我的方法甚至可能吗?

4

1 回答 1

0

我遇到了同样的问题,我所做的只是在 TransferEvent 上,我用初始源广告重新创建了 pickList 目标和事件目标,就像在这个例子中一样

List<String> initialSource;

...(Code to fill the initial list)...

public void onTransferSeccion(TransferEvent event){
    originalPickList= new DualListModel(initialSource, originalPickList.getTarget());
}
于 2016-09-08T18:38:47.100 回答