You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arno Claassen <Ar...@Informatik.Uni-Oldenburg.DE> on 2007/08/30 15:52:23 UTC

Iterating a collection: changing values of object-attributes
Hi there!

I'm new to struts and need some help, hope anybody has a clue:
I've got an object "DayTimeLocation" with strings day, time and location.

In my form I create a collection with initially one of these objects (more to follow):

public class DayTimeLocationForm extends ActionForm{
     Collection<DayTimeLocation> dtlCollection;

     public void reset(ActionMapping mapping, HttpServletRequest request) {
         dayTimeLocation dtl = new dayTimeLocation("Monday", "08:00", "University");
         Collection<dayTimeLocation> dtlTempCollection = new ArrayList<DayTimeLocation>();
         dtlTempCollection.add(dtl);
         this.dtlCollection = dtlTempCollection;
     }

     public Collection<DayTimeLocation> getDtlCollection() {
         return dtlCollection;
     }

     public void setDtlCollection(Collection<DayTimeLocation> dtlCollection) {
         this.dtlCollection = dtlCollection;
     }
}

Now the jsp with a selectlist and textfields for changing the attributes 
of the objects in that collection:

<logic:iterate id="dtl" name="DayTimeLocationFormBN" 
property="dtlCollection">
                <html:select name="dtl" property="day" size="1" indexed="true">
                        <html:option value="Monday">Monday</html:option>
                        <html:option value="Tuesday">Tuesday</html:option>
                        <html:option value="Wednesday">Wednesday</html:option>
                        <html:option value="Thursday">Thursday</html:option>
                        <html:option value="Friday">Friday</html:option>
                        <html:option value="Saturday">Saturday</html:option>
                        <html:option value="Sunday">Sunday</html:option>
                </html:select>
                <html:text name="dtl" property="time" size="5" maxlength="5" indexed="true"/>
                <html:text name="dtl" property="location" size="10" maxlength="10" indexed="true"/></br>
</logic:iterate>

First this seemed to work, because the fields of the page contain the values declared in the reset-method.
But after changing the values on the page and committing them to the action, it gets the old values (from reset) and not the new ones.
The struts-config etc. is not the problem, other things work fine. Where is my mistake?
Thank you in advance!

Arno

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org