문제

해시 맵을 통해 반복하고 해시 맵의 키를 가진 숫자 확인란을 표시하고 해시 맵의 값에 레이블을 지정합니다. 누구든지 태피스트리 구문이 어떻게되는지 아는 사람이 있습니까?

Dimitris를 건배합니다

도움이 되었습니까?

해결책

다음과 같은 키 세트를 살펴볼 수 있어야합니다.

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

나는 이것을 편집하지 않았지만, 당신이 시작하는 데 도움이 될 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top