How can I append the loop index of a c:forEach tag to the attributes of a struts select/text tag?
For example.
<%@ 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>
throws the following error
javax.servlet.jsp.JspException at org.apache.struts.taglib.html.SelectTag.calculateMatchValues(SelectTag.java:246)
Now, when I debug the code at <html:select ...
it shows that when the property attribute it set, its set as "title_guest<c:out value="${gC.index}"/>"
which could be the cause of the exception above.
Also, I should mention, that if I use the above format for appending the loop index to a standard html tag attribute like a <select>
tag, the code works fine.
For example
<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>
Correctly outputs the intended HTML
What am I doing wrong, should I be using EL to create the string that will populate the "property" attribute of the html:select tag?
UPDATE
The following snippet was also tried and that didn't work either
<html:select property="title_guest${gC.index}">
And, neither does this 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>