Je migre struts1 vers le projet web struts2. Voici le code struts1.en utilisant struts2 sélectionnez sans appliquer d'attribut de liste, utilisez plutôt l'option -> est-ce que c'est OK?
<html:select property="dobYear" styleId="dobYear" styleClass="text_field text2" style="width:70px" onchange="loadDayOptions(this.options[this.options.selectedIndex].value, getElement('dobMonth').options[getElement('dobMonth').options.selectedIndex].value, getElement('dobDay'));">
<html:option value="">--</html:option>
<%
int thisYear = Calendar.getInstance().get(Calendar.YEAR);
int fromYear = thisYear - 17;
int toYear = 1900;
for(int i=fromYear; i>=toYear; i--){
%>
<html:option value="<%=String.valueOf(i) %>"><%=String.valueOf(i) %></html:option>
<% } %>
</html:select>
Si je veux ci-dessous le code à l'aide struts2 s: sélectionnez mais sans utiliser l'attribut de liste, au lieu d'utiliser <option>
, est-il correct? Suis ma syntaxe correcte?
<s:select value="#{editForm.dobYear}" name="editForm.dobYear" id="dobYear" styleClass="text_field text2" style="width:70px" onchange="loadDayOptions(this.options[this.options.selectedIndex].value, getElement('dobMonth').options[getElement('dobMonth').options.selectedIndex].value, getElement('dobDay'));">
<option value="">--</option>
<%
int thisYear = Calendar.getInstance().get(Calendar.YEAR);
int fromYear = thisYear - 17;
int toYear = 1900;
for(int i=fromYear; i>=toYear; i--){
%>
<option value="<%=String.valueOf(i) %>"><%=String.valueOf(i) %></option>
<% } %>
</s:select>