Thymeleaf suggests dropdown creation as follows:
<select th:field="*{type}">
<option th:each="type : ${allTypes}"
th:value="${type}"
th:text="#{${'seedstarter.type.' + type}}">Wireframe
</option>
</select>
However, if you want to have a 'selected' option this would not work:
<select th:field="*{type}">
<option th:each="type : ${allTypes}"
th:value="${type}"
th:text="#{${'seedstarter.type.' + type}}"
th:selected="${myCondition}">Wireframe
</option>
</select>
Instead you should do:
<select name="type">
<option th:each="type : ${allTypes}"
th:value="${type}"
th:text="#{${'seedstarter.type.' + type}}"
th:selected="${myCondition}">Wireframe
</option>
</select>
<select th:field="*{type}">
<option th:each="type : ${allTypes}"
th:value="${type}"
th:text="#{${'seedstarter.type.' + type}}">Wireframe
</option>
</select>
However, if you want to have a 'selected' option this would not work:
<select th:field="*{type}">
<option th:each="type : ${allTypes}"
th:value="${type}"
th:text="#{${'seedstarter.type.' + type}}"
th:selected="${myCondition}">Wireframe
</option>
</select>
Instead you should do:
<select name="type">
<option th:each="type : ${allTypes}"
th:value="${type}"
th:text="#{${'seedstarter.type.' + type}}"
th:selected="${myCondition}">Wireframe
</option>
</select>
What is ${myCondition} there .Please Explain
ReplyDeleteIt's any condition you like. For instance:
ReplyDeleteth:selected="${a>b}">Wireframe
Play Baccarat, Craps, Blackjack - Free Play | FBCASINO
ReplyDeleteBaccarat, 바카라 사이트 Craps, Blackjack. Play this game 인카지노 for free, in demo mode. No sign-in or download necessary! febcasino