Hi Cristoph,

Order may be important to him if he has web server rewrite rules in place. 
AARON ROSENZWEIG / Chat 'n Bike
e:  [email protected]  t:  (301) 956-2319             
        

On May 22, 2014, at 5:39 PM, CHRISTOPH WICK | i4innovation GmbH, Bonn 
<[email protected]> wrote:

> Hi John,
> 
> If you read the documentation of WORequest's formValueKeys method, it says:
> 
> "The returned array is not sorted in any particular order, and is not 
> necessarily sorted in the same order on successive invocations of this 
> method."
> 
> (http://wocommunity.org/documents/javadoc/WebObjects/5.4.2/com/webobjects/appserver/WORequest.html#formValueKeys())
> 
> So I assume your workaround will not work always (even if it does sometimes), 
> since you assume, that request.formValueKeys() gives you the right order.
> 
> If you really care about the order of the key-value-pairs in the URI, I think 
> you have to parse the query string manually. 
> 
> Take a look  at NSArray's wonderful method 
> "componentsSeparatedByString(String string, String separator)" and apply it 
> to your WORequest's method "queryString()" with separator "&". then a second 
> time on each key-value-pair with separator "=" and then you should have the 
> key at "objectAtIndex(1)" in the same order as within the queryString.
> 
> C.U.CW
> 
> P.S.: What's the reason you want to know the exact order? I haven't needed 
> such a thing in many years of web development.
> 
> -- 
> What are the three enemies of a programmer? Sunlight, oxygen, and the 
> appalling roar of the birds.
> 
> 
> On 21.05.2014, at 18:56, John Pollard <[email protected]> wrote:
> 
>> My workaround to put them back in order, using a TreeMap to sort on the 
>> index position within the URI.
>> 
>>       NSArray<String> formKeys = request().formValueKeys();
>>       String uriStr = request().uri();
>>       TreeMap<Integer, String> orderedKeysMap = new TreeMap<Integer, 
>> String>();
>>       for(String nextKey : formKeys)
>>       {
>>              orderedKeysMap.put(uriStr.indexOf(nextKey), nextKey);
>>       }   
>> 
>> On 21 May 2014, at 17:26, John Pollard <[email protected]> wrote:
>> 
>>> Hi List,
>>> 
>>> I note that WORequest.formValues() jumbles up the order of the values from 
>>> a url. Is there a simple way to get them in order, or do I need to parse 
>>> them out myself? I understand that normally the order shouldn't be 
>>> important, but I have what I feel is a reasonable purpose for needing to 
>>> know the order.
>>> 
>>> Thanks
>>> John
>> 
>> 
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/cw%40i4innovation.de
>> 
>> This email sent to [email protected]
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/aaron%40chatnbike.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to