struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Puneet Lakhina" <puneet.lakh...@gmail.com>
Subject Indexed Properties. Maintaining Order
Date Thu, 21 Sep 2006 09:43:08 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message