在使用项目填充Alloy UI组合框后,如何设置所选项目? 我的意思是,插入组合框的其中一个项目应该是默认的选定项目。我怎么设置它?
答案 0 :(得分:3)
JSP:
<aui:select name="selectedCity" label="City:" id="selectedCity">
<c:forEach items="${cities}" var="city">
<aui:option value="${city}" label="${city}" selected="${selectedCity == city}"/>
</c:forEach>
</aui:select>
的java:
renderRequest.setAttribute("selectedCity", selectedCity);
List<String> cities = Lists.newArrayList("New Yourk", "Moskau", "London", "Rom");
renderRequest.setAttribute("cities", cities);