struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Addy Kapur <>
Subject Re: Struts 1.1 iterate woes
Date Sun, 03 Oct 2004 19:55:20 GMT
I have used the following syntax and it works.

 <logic:iterate name="BForm" property="bVO.lines" id="bAmount" indexId="idx">
              <html:hidden property="<%="bVO.bLine["+idx+"].name"%>"/>
                    <html:hidden property="<%="bVO.bLine["+idx+"].id"%>"/>
                    <html:hidden property="<%="bVO.bLine["+idx+"].amount"%>"/>

On Sun, 3 Oct 2004 14:16:19 -0400, Victor Grazi <> 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: 
> For additional commands, e-mail: 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message