No worries. Your stuff's a bit confusing. On your <html:form> you have an action named "interest" and you don't specify a "name" attribute on your <html:checkbox>. That means the checkbox tag is going to try and get the form associated with your "interest" action (if it doesn't exist, it'll try and create it) and then try to retrieve the property you named which is "${interest.code}", plus the fact you are storing a "interests" object in request scope.
I changed your code and the following worked for me, the only difference is I don't use the "el" versions of the struts tags - just the standard ones: <% java.util.ArrayList interests = new java.util.ArrayList(); java.util.HashMap map = new java.util.HashMap(); map.put("code","ABC"); interests.add(map); request.setAttribute("interests",interests); %> <c:forEach var="interest" items="${interests}"> <p>Interest: <html:text indexed="true" name="interest" property="code"/></p> </c:forEach> ... and it produced: <p>Interest: <input type="text" name="interest[0].code" value="ABC"></p> Niall ----- Original Message ----- From: "Paul Barry" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Thursday, May 06, 2004 8:55 PM Subject: Re: indexed="true" is only valid within an enclosing iterate tag > Sorry for replying directly to you Niall. I meant to reply to the whole > list. I think when you reply to a message you are replying to the user > list and me individually, because I get two copies of each message that > you post. The reply-to on one of them it set to the struts user list, > and the reply-to on the other is set to your address, so I guess I > replied to the wrong one. > > Anyway, here is the full code: > > <%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" > prefix="html" %> > <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic-el" > prefix="logic" %> > <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> > <html:html> > <body> > <% > java.util.ArrayList interests = new java.util.ArrayList(); > java.util.HashMap map = new java.util.HashMap(); > map.put("code","ABC"); > interests.add(map); > request.setAttribute("interests",interests); > %> > <html:form action="interest"> > <c:forEach var="interest" varStatus="loop" items="${interests}"> > <html:checkbox indexed="true" property="${interest.code}"/> > </c:forEach> > </html:form> > </body> > </html:html> > > > The JSP scriplet fakes what normally happens in a action before getting > to the JSP. Here is the exceptioin I get: > > javax.servlet.jsp.JspException: indexed="true" is only valid within an > enclosing iterate tag > at > org.apache.struts.taglib.html.BaseHandlerTag.prepareIndex(BaseHandlerTag.jav a:663) > at > org.apache.struts.taglib.html.CheckboxTag.doStartTag(CheckboxTag.java:188) > at > org.apache.strutsel.taglib.html.ELCheckboxTag.doStartTag(ELCheckboxTag.java: 531) > at _test__jsp._jspService(/test.jsp:14) > at com.caucho.jsp.JavaPage.service(JavaPage.java:75) > at com.caucho.jsp.Page.subservice(Page.java:506) > at > com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182) > at com.caucho.server.http.Invocation.service(Invocation.java:315) > at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246) > at > com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163) > at com.caucho.server.TcpConnection.run(TcpConnection.java:139) > at java.lang.Thread.run(Thread.java:536) > > > Is it possible that this problem has something to do with me using > resin? Guess I could download and setup tomcat to test... > > Niall Pemberton wrote: > > > Well it works fine for me - so I'm at a loss to explain. Maybe you should > > post the actual jsp code you are using - you said the jsp code looked like > > this: > > > > <c:forEach var="item" items="${items}"> > > <html:text name="item" property="code"/> > > </c:forEach> > > > > but the exception you show is for the EL version of the checkbox tag. > > > > Also its better if you post to the struts user list rather than directly to > > me - someone who knows more than me or has experienced your problem may jump > > in if you post to the list. > > > > Niall > > > > > > ----- Original Message ----- > > From: "Paul Barry" <[EMAIL PROTECTED]> > > To: "Niall Pemberton" <[EMAIL PROTECTED]> > > Sent: Thursday, May 06, 2004 1:42 PM > > Subject: Re: indexed="true" is only valid within an enclosing iterate tag > > > > > > > >>I am using Struts 1.1, I just copied jstl.jar, struts.jar and > >>struts-el.jar into my project lib directory to be sure. Still getting > >>the exception: > >> > >>javax.servlet.jsp.JspException: indexed="true" is only valid within an > >>enclosing iterate tag > >>at > >> > > > > org.apache.struts.taglib.html.BaseHandlerTag.prepareIndex(BaseHandlerTag.jav > > a:663) > > > >>at > >>org.apache.struts.taglib.html.CheckboxTag.doStartTag(CheckboxTag.java:188) > >>at > >> > > > > org.apache.strutsel.taglib.html.ELCheckboxTag.doStartTag(ELCheckboxTag.java: > > 531) > > > >>I checked the source code around line 663 of BaseHandlerTag, here is > >>what it looks like: > >> > >>// Look for JSTL loops > >>if (iterateTag == null) { > >> Integer i = getJstlLoopIndex(); > >> if (i != null) { > >>index = i.intValue(); > >>found = true; > >> } > >>} else { > >> index = iterateTag.getIndex(); > >> found = true; > >>} > >> if (!found) { > >> // this tag should only be nested in iteratetag, if it's > >>not, throw exception > >> JspException e = new > >>JspException(messages.getMessage("indexed.noEnclosingIterate")); > >> RequestUtils.saveException(pageContext, e); > >> throw e; > >> } > >> > >> > >>Seems as though getJstlLoopIndex() isn't doing it's job, any ideas why? > >> I have tried it with declaring the Loop Status in the c:forEach with > >>varStatus="loop" and without, still get the exception. > >> > >>Niall Pemberton wrote: > >> > >> > >>>Hmmm. The thinking behind my suggestion was "is jstl working properly > > > > for > > > >>>you or is the indexed thing just hinding some other root cause" > >>> > >>>I'm out of ideas - the only other thing I can think of is what version > > > > of > > > >>>Struts are you using - I believe jstl was only catered for from Struts > > > > 1.1 - > > > >>>so if you were using a version before that you would get the message > > > > you're > > > >>>seeing. > >>> > >>>Niall > >>> > >>>----- Original Message ----- > >>>From: "Paul Barry" <[EMAIL PROTECTED]> > >>>To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >>>Sent: Wednesday, May 05, 2004 10:21 PM > >>>Subject: Re: indexed="true" is only valid within an enclosing iterate > > > > tag > > > >>> > >>> > >>>>Yeah, if I remove the indexed="true", my JSP code looks like this: > >>>> > >>>><c:forEach var="item" items="${items}"> > >>>> <html:text name="item" property="code"/> > >>>></c:forEach> > >>>> > >>>>I get a bunch of HTML inputs like this: > >>>> > >>>><input type="text" name="code" value="ABC" /> > >>>> > >>>>With different values but all named code. Code is a property of item, > >>>>and each item in items has a different code. > >>>> > >>>>Niall Pemberton wrote: > >>>> > >>>> > >>>> > >>>>>What happens if you remove the "indexed" attribute from all the > >>>>><html:text> - does it work properly then (except for the "name" > >>> > >>>attribute) > >>> > >>> > >>>>>is the html page generated OK? > >>>>> > >>>>>Niall > >>>>> > >>>>>----- Original Message ----- > >>>>>From: "Paul Barry" <[EMAIL PROTECTED]> > >>>>>To: <[EMAIL PROTECTED]> > >>>>>Sent: Wednesday, May 05, 2004 9:49 PM > >>>>>Subject: indexed="true" is only valid within an enclosing iterate tag > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>>>I am trying to use indexed properties in a form, as described in James > >>>>>>Turner's Article "Succeeding With Struts: Indexed Properties and Beans > >>>>>>as Properties" at > > > > http://www.developer.com/java/ejb/article.php/2233591 > > > >>>>>>The example shows you can use c:forEach with <html:text > >>>>>>indexed="true"/>, like this: > >>>>>> > >>>>>><c:forEach var="lines" items="${purchaseOrderBeanForm.map.lines}" > > >>>>>> <TR><TD><html:text indexed="true" name="lines" > >>>>>>property="partNumber"/></TD> > >>>>>> <TD><html:text indexed="true" name="lines" > > > > property="quantity"/></TD> > > > >>>>>> <TD><html:text indexed="true" name="lines" > >>> > >>>property="price"/></TD></TR> > >>> > >>>>>></c:forEach> > >>>>>> > >>>>>>But when I try to do that, I get this error: > >>>>>> > >>>>>>indexed="true" is only valid within an enclosing iterate tag > >>>>>> > >>>>>>Is my code wrong or is the example wrong? > >>>>>> > >>>>>>--------------------------------------------------------------------- > >>>>>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>>>For additional commands, e-mail: [EMAIL PROTECTED] > >>>>>> > >>>>>> > >>>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>>--------------------------------------------------------------------- > >>>>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>>For additional commands, e-mail: [EMAIL PROTECTED] > >>>>> > >>>> > >>>>--------------------------------------------------------------------- > >>>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>For additional commands, e-mail: [EMAIL PROTECTED] > >>>> > >>>> > >>>> > >>> > >>> > >>> > >> > >> > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]