Цикл гобелена через hashmap

Я пытаюсь циклично выполниться через hashmap и отобразить число флажки с идентификатором ключ hashmap и маркировать значение hashmap. Кто-либо знает, как синтаксис гобелена для этого?

Аплодисменты Dimitris

9
задан Sfairas 12 March 2010 в 14:36
поделиться

1 ответ

Вы должны иметь возможность перебирать набор ключей следующим образом:

<form t:type="Form">
    <t:Loop t:source="myMap.keySet()" t:value="currentKey"> 
        <input type="Checkbox" t:type="Checkbox" t:id="checkbox"
            t:value="currentValue"/>
        <label t:type="Label" for="checkbox">${mapValue}</label>
    </t:Loop>
</form>

Файл класса:

@Property
private Object currentKey;

@Persist
private Set<String> selection = new HashSet<String>();

public Map<String,String> getMyMap() {
    ...
}

public boolean getCurrentValue() {
     return this.selection.contains(this.currentKey);
}

public void setCurrentValue(final boolean currentValue) {
    final String mapValue = this.getMapValue();

    if (currentValue) {
        this.selection.add(mapValue);
    } else {
        this.selection.remove(mapValue);
    }
}


public String getMapValue() {
    return this.getMyMap().get(this.currentKey);
}

Я не скомпилировал это, но он должен помочь вам начать работу.

14
ответ дан 4 December 2019 в 14:28
поделиться
Другие вопросы по тегам:

Похожие вопросы: