How can I add a c: forEach tag loop index to the attributes of a select attribute or a text tag?
For instance.
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%> <c:forEach begin="2" end="${pageView.guestCount}" varStatus="gC"> <div class="section guest-details"> <html:select property='title_guest<c:out value="${gC.index}"/>'> <html:options collection="titles" property="code" labelProperty="value" /> </html:select> </div> </c:forEach>
produces the following error
javax.servlet.jsp.JspException at org.apache.struts.taglib.html.SelectTag.calculateMatchValues(SelectTag.java:246)
Now, when I debug the code in <html:select ... , it shows that with the property attribute set, its value "title_guest<c:out value="${gC.index}"/>" may be the cause of the above exception.
In addition, I should mention that if I use the above format to add a loop index to the standard attribute of the html tag, such as the <select> , the code works fine.
for instance
<c:forEach begin="2" end="${pageView.guestCount}" varStatus="gC"> <div class="section guest-details"> <select name='title_guest<c:out value="${gC.index }"/>'> <option value="">Select Title</option> </select> </div> </c:forEach>
The correct HTML output
What am I doing wrong, should I use EL to create a string that will populate the property attribute of the html: select tag?
UPDATE
The following snippet was also tested, and this did not work <html:select property="title_guest${gC.index}">
And it also does not work
<c:set var="guestTitle">title_guest${gC.index}</c:set> <html:select property="${guestTitle}" styleClass="{required: true}"> <html:options collection="titles" property="code" labelProperty="value" /> </html:select>
source share