I have to admit I always have trouble dealing with the iterate tag. I recently rediscovered how easy it is to do these iterations using the nested tags. Have you tried them? Maybe something like this would work for you:
<html:form action="/test"> <nested:iterate property="list"> <nested:write property="id" /><br> <nested:text property="description" onchange="changefield(this);"/><br> <nested:hidden property="isChanged" /><br> </nested:iterate> <html:submit>Send</html:submit> </html:form> I don't know if it's considered "best practice" to also surround the form with <nested:form>, but I've tried using the basic <html:form> and it works fine, too. The result is code I can actually understand. :) If you want to stick to the html tags, take a look at the example in http://wiki.apache.org/struts/StrutsCatalogLazyList hth, Hubert On Sun, 3 Oct 2004 14:16:19 -0400, Victor Grazi <[EMAIL PROTECTED]> wrote: > We are trying to use <logic:iterate> in a JSP to access items in a list > stored in the Form Bean by the Action class but we can't seem to get the > syntax right. > > I am getting an error meessage from PropertyUtils that displays the index as > '${index}', which indicates that that struts el expression is not resolving > to an int. > > Here is my exact syntax. The form and action are described in more detail > below. > > <html:form action="/test"> > <logic:iterate id="lineItem" indexId="index" name="testForm" > property="list"> > > <!-- display the index counter for the fun of it. This works > ok --> > <bean:write name="index" /><br> > > <!-- now access the id of the indexth element of the list > --> > <bean:write name="list[${index}].id" /><br> > > <!-- now access the description of the indexth element of > the list --> > <html:text property="list[${index}].description" > onchange="changefield(this);"/><br> > <html:hidden property="isChanged[${index}]" /><br> > > </logic:iterate> > <html:submit>Send</html:submit> > </html:form> > > I have created several Test classes to help me understand the flow... > > The form is an instance of TestForm exends ActionForm and its form name in > struts-config.xml is "testForm". (This is the named form for the action.) > TestForm has one property: java.util.List list with accessors public List > getList() and public void setList(List list). > > List is always a List of LineItem objects where LineItem is a simple > JavaBean with properties > String id (public String getId() and public void setId(String id)), String > description (public String getDescription() and public void > setDescription(String description)) and boolean isChanged (public void > setIsChanged(boolean value) and public boolean getIsChanged() ) > > The Action (TestAction extends Action) "execute" method creates a List of 5 > LineItem objects and stores that List into the form by calling > ((TestForm)form).setList(list), then forwards to the jsp (test.jsp) > > In the jsp I would like to iterate through the list to perform the > following: > display the id (as html read-only text) and the > description (as html:text) of each line item, > then use JavaScript to change the "isChanged" property (in a hidden field) > when the onchange event is triggered. > > I have tried several different syntaxes. I also tried using arrays instead > of List's. I also specified the type of the LineItem class explicitly in the > form element. I tried each of the "html:" and "bean:write" lines above one > at a time to see if any would be successful, but they all produce that same > error. I have combed the web for a good example of how to accomplish this, > but I couldn't find anything that handled things in a way that would work > for us. > > Can you tell me what I am doing wrong and how to accomplish the access? > > Thanks/Victor > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]