问题
After filling an Alloy UI combo box with items, How can I set the Selected Item? I mean, one of the items inserted into combo box should be the default selected item. How I can set that?
回答1:
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);
来源:https://stackoverflow.com/questions/10262253/how-to-set-the-selected-item-in-alloy-ui-combo-box