A List is an ordered collection so it doesnt make sense that the order changes. 
 Also, depending on which Map implementation you use ordering may not be 
guaranteed.  I frequently use indexed properties with List and have not 
experienced this problem.  You may need to check the generated html source and 
follow through the request cycle.
 
Your method signatures for your setters dont seem appropriate in the context of 
managing indexed properties on a list of objects (at least to me).  Perhaps you 
are managing your indexed properties in a way that would better suit a Map 
implementation, but I cant tell from the provided code.

________________________________

From: Puneet Lakhina [mailto:[EMAIL PROTECTED]
Sent: Thu 21/09/2006 7:43 PM
To: Struts Users Mailing List
Subject: Indexed Properties. Maintaining Order



Hi,
I have a no. of fields in a form arranged in a table of rows. I am using
indexed properties for these fields. The number of these fields isn't known
to me at the time of page loading for which I have used some DHTML to
properly add the fields. And all the values are getting submitted.
Now my problem is that the order is getting jumbled up.

My table is like this

No.           Date               Description
1.              date[0]                description[0]
2.               date[1]                description[1]

But after submitting, the order gets jumbled up. i.e. i get something like
this

No.           Date               Description
1.              date[0]                description[1]
2.               date[1]                description[0]

This I have figured is because of the following setter methods

public void setDate(int index,String value) {
datesList.add(value);
}

public void setDescription(int index,String value) {
descriptionsList.add(value);
}

So basically the order in which the setter methods are called is random. i.e.
setDate(0,value) - >  setDescription(1,value)  and so on.
Does this problem mean we have no way of maintaining order when using lists?


What I have thought of is instead of using Indexed Properties I will use
map backed properties. But if somebody can offer me some sort of solution
that doesn't require change from Lists to Map it would be great.


--
Puneet


**********************************************************************
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**********************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to