2
votes

I implemented a picklist in my Project.

Docu for picklist

I tried to change the logic of this view to fit my actions. I want to leave the SourceList as it is and only change the targetList if the given itemScope isn't already in targetList.

My approach:

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

This works logically with the DualList because it returns the right filled List, but its kinda a workaround and dirty. The Problem here is it still removes the Item in the view.

Is my approach even possible?

1

1 Answers

0
votes

I had the same problem, all I did was on the TransferEvent, I recreated the pickList with the initial Source ad the target with the event target like in this example

List<String> initialSource;

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

public void onTransferSeccion(TransferEvent event){
    originalPickList= new DualListModel(initialSource, originalPickList.getTarget());
}