You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Tobias Bocanegra (JIRA)" <ji...@apache.org> on 2009/11/10 22:33:27 UTC

[jira] Created: (SLING-1178) Preserve request parameter order throughout the entire request stack

Preserve request parameter order throughout the entire request stack
--------------------------------------------------------------------

                 Key: SLING-1178
                 URL: https://issues.apache.org/jira/browse/SLING-1178
             Project: Sling
          Issue Type: Improvement
          Components: Engine, Servlets
    Affects Versions: Engine 2.0.6, Servlets Post 2.0.4
            Reporter: Tobias Bocanegra
            Priority: Minor
         Attachments: ordered_params-r834673.patch

When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
even the browser sends the params according to the submitted form.

for example the following form:

<form name="input" action="/content/testform" method="POST">
           <input type="hidden" name="./sendTo@Delete"/><br/>
Address 0: <input type="text" name="./sendTo/0/address" /><br/>
   Text 0: <input type="text" name="./sendTo/0/text" /><br/>
Address 1: <input type="text" name="./sendTo/1/address" /><br/>
   Text 1: <input type="text" name="./sendTo/1/text" /><br/>
Address 2: <input type="text" name="./sendTo/2/address" /><br/>
   Text 2: <input type="text" name="./sendTo/2/text" /><br/>
           <input type="submit" value="Submit" />
</form>

results in:

deleted("/content/testform/sendTo");
created("/content/testform/sendTo");
created("/content/testform/sendTo/2");
modified("/content/testform/sendTo/2/address");
modified("/content/testform/sendTo/2/text");
created("/content/testform/sendTo/1");
modified("/content/testform/sendTo/1/text");
created("/content/testform/sendTo/0");
modified("/content/testform/sendTo/0/text");
modified("/content/testform/sendTo/0/address");
modified("/content/testform/sendTo/1/address");

i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:

  Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();

but the params arrive out of order already from the request.getParameterMap().

i guess the "ParameterMap" needs to extend from LinkedHashMap, too:

class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...

after fixing those 2 classes, the order is correct:

deleted("/content/testform/sendTo");
created("/content/testform/sendTo");
created("/content/testform/sendTo/0");
modified("/content/testform/sendTo/0/address");
modified("/content/testform/sendTo/0/text");
created("/content/testform/sendTo/1");
modified("/content/testform/sendTo/1/address");
modified("/content/testform/sendTo/1/text");
created("/content/testform/sendTo/2");
modified("/content/testform/sendTo/2/address");
modified("/content/testform/sendTo/2/text");

i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776328#action_12776328 ] 

Felix Meschberger commented on SLING-1178:
------------------------------------------

> but the params arrive out of order already from the request.getParameterMap().

Actually the parameters already arrive "out of order" from ServletRequest.getParameterMap() implemented by the servlet container.

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Priority: Minor
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776407#action_12776407 ] 

Alexander Klimetschek commented on SLING-1178:
----------------------------------------------

> ok. i agree that the servlet spec does not define the order of the request parameters. however, multipart/form-data does

The html spec does that for application/x-www-form-urlencoded as well, see http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1

    2. The control names/values are listed in the order they appear in the document.

The servlet spec is to blame here. Maybe it will get fixed in a new version ;-) so it's good that Sling does not fiddle with the ordering.

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: Servlets Post 2.0.6, Engine 2.1.0
>
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776389#action_12776389 ] 

Felix Meschberger commented on SLING-1178:
------------------------------------------

Fixed RequestParameterMap implementation to be based on LinkedHashMap (also ensure the internal string value cache is based on a LinkedHashMap) in Rev. 834819.

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Priority: Minor
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776398#action_12776398 ] 

Felix Meschberger commented on SLING-1178:
------------------------------------------

Updated documentation on request parameters and the Sling Post Servlet with respect to this new parameter ordering support.

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: Servlets Post 2.0.6, Engine 2.1.0
>
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776327#action_12776327 ] 

Felix Meschberger commented on SLING-1178:
------------------------------------------

This looks good at first sight, but has a serious drawback: The Servlet Spec defines the result of ServletRequest.getParameterMap as java.util.Map. This implies that there exists no explicit parameter ordering. In fact the spec does not even talk about parameter ordering. From this I conclude there is no inherent parameter ordering provided by the servlet container.

Hence introducing a parameter ordering on the Sling level just gives a false impresssion, IMHO.

Therefore -1 to this.

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Priority: Minor
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Tobias Bocanegra (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tobias Bocanegra updated SLING-1178:
------------------------------------

    Attachment: ordered_params-r834673.patch

patch that solves this issue

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Priority: Minor
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776334#action_12776334 ] 

Carsten Ziegeler commented on SLING-1178:
-----------------------------------------

I agree with Felix, if there needs to be an ordering because of the stuff that is done with the params, this should be done server side, so first process deletes, then create and then modify.

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Priority: Minor
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776425#action_12776425 ] 

Felix Meschberger commented on SLING-1178:
------------------------------------------

Thanks for the clarification.

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: Servlets Post 2.0.6, Engine 2.1.0
>
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776386#action_12776386 ] 

Felix Meschberger commented on SLING-1178:
------------------------------------------

ok, got me. thanks for the link.

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Priority: Minor
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger resolved SLING-1178.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: Engine 2.1.0
                   Servlets Post 2.0.6
         Assignee: Felix Meschberger

Applied the patch to the Post Servlet's ModifyOperation in Rev. 834821

This should preserve the multipart/form-data parameters

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Assignee: Felix Meschberger
>            Priority: Minor
>             Fix For: Servlets Post 2.0.6, Engine 2.1.0
>
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-1178) Preserve request parameter order throughout the entire request stack

Posted by "Tobias Bocanegra (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12776384#action_12776384 ] 

Tobias Bocanegra commented on SLING-1178:
-----------------------------------------

ok. i agree that the servlet spec does not define the order of the request parameters.
however, multipart/form-data does:

http://www.w3.org/TR/html401/interact/forms.html, 17.13.4 Form content types
...
A "multipart/form-data" message contains a series of parts, each representing a successful control. The parts are sent to the processing agent in the same order the corresponding controls appear in the document stream. Part boundaries should not occur in any of the data; how this is done lies outside the scope of this specification.
...


and since a multipart-post is also exposed via the request parameter map, i have no possibility to decompose the multipart post myself if i want to preserve the order of the parameters (parts).

> Preserve request parameter order throughout the entire request stack
> --------------------------------------------------------------------
>
>                 Key: SLING-1178
>                 URL: https://issues.apache.org/jira/browse/SLING-1178
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine, Servlets
>    Affects Versions: Servlets Post 2.0.4, Engine 2.0.6
>            Reporter: Tobias Bocanegra
>            Priority: Minor
>         Attachments: ordered_params-r834673.patch
>
>
> When posting a form to the sling post servlet i encountered that the order of the request parameters is not preserved,
> even the browser sends the params according to the submitted form.
> for example the following form:
> <form name="input" action="/content/testform" method="POST">
>            <input type="hidden" name="./sendTo@Delete"/><br/>
> Address 0: <input type="text" name="./sendTo/0/address" /><br/>
>    Text 0: <input type="text" name="./sendTo/0/text" /><br/>
> Address 1: <input type="text" name="./sendTo/1/address" /><br/>
>    Text 1: <input type="text" name="./sendTo/1/text" /><br/>
> Address 2: <input type="text" name="./sendTo/2/address" /><br/>
>    Text 2: <input type="text" name="./sendTo/2/text" /><br/>
>            <input type="submit" value="Submit" />
> </form>
> results in:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/text");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/1/address");
> i first thought it's just the ModifyOperation which uses a HashMap instead of a LinkedHashMap:
>   Map<String, RequestProperty> reqProperties = new HashMap<String, RequestProperty>();
> but the params arrive out of order already from the request.getParameterMap().
> i guess the "ParameterMap" needs to extend from LinkedHashMap, too:
> class ParameterMap extends LinkedHashMap<String, RequestParameter[]> ...
> after fixing those 2 classes, the order is correct:
> deleted("/content/testform/sendTo");
> created("/content/testform/sendTo");
> created("/content/testform/sendTo/0");
> modified("/content/testform/sendTo/0/address");
> modified("/content/testform/sendTo/0/text");
> created("/content/testform/sendTo/1");
> modified("/content/testform/sendTo/1/address");
> modified("/content/testform/sendTo/1/text");
> created("/content/testform/sendTo/2");
> modified("/content/testform/sendTo/2/address");
> modified("/content/testform/sendTo/2/text");
> i'll attach the patch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.