2005/11/29, Nicolas Lehuen <[EMAIL PROTECTED]>: > 2005/11/29, Mike Looijmans <[EMAIL PROTECTED]>: > > Nicolas Lehuen wrote: > > > Why is the ordering so important ? I do understand we need to support > > > multiple values per field name, but I don't see why ordering is > > > needed. > > > > Because there are applications out there that will break if you change > > it. Besides that, think about a form with a few text entry boxes (all > > the same name, e.g. "spouse"). It would be very confusing for a user of > > that page to see the text re-ordered every time he clicks one of the > > buttons on the page. (I'm perfectly aware of at least 4 alternatives, > > but that is not my point here). > > > > From the page code I've written and seen so far, the order of > > differently named fields is not important. I haven't seen a case where > > a form expecting a=1&b=2 would fail if you pass it b=2&a=1. But I have > > seen cases where a=1&x=2&x=3 is not the same as a=1&x=3&x=2. The simple > > dictionary implementation as proposed would not break that code. > > > > > > -- > > Mike Looijmans > > Philips Natlab / Topic Automation > > > > > > Hi Mike, > > As Jim pointed out, even if using a simple dict structure would not > enable us to preserve the *key* ordering, it would still allow us to > preserve the *value* ordering for fields with the same key, since they > would be added to lists in the same order the browser would send them. > > So my guess is that preserving key order is not required, but > preserving value order for a given key is. In that case a simple dict > with list values is sufficient, easy to implement and efficient. Your > examples are easily handled with this solution. > > I think we should check how this problem has been solved in other > programming environments. I'll check how this was done in the Java > servlet API.
Well, the Java Servlets 2.4 API doesn't say anything about field order (see in javax.servlet.ServletRequest.getParameterName() or page 35 in servlet-2_4-fr-spec.pdf). It turns out this problem was raised in the antique JServ project : http://archive.apache.org/gnats/5211 One proposal was to use an OrderedHashtable. As you can see, the reply was quite definite : "No. There is nothing in the spec that says that these parameters should be in any sort of order. CGI scripts that expect them to be in order are coded incorrectly IMHO." Regards, Nicolas