[ http://issues.apache.org/jira/browse/COCOON-1864?page=all ]
     
Antonio Gallardo closed COCOON-1864:
------------------------------------

    Fix Version: 2.2-dev (Current SVN)
                 2.1.10-dev (current SVN)
     Resolution: Fixed

Thanks for your contribution. The patch applied. Feel free to reopen the issue 
if needed.

> RepeaterJXPathBinding - order of row is inverted
> ------------------------------------------------
>
>          Key: COCOON-1864
>          URL: http://issues.apache.org/jira/browse/COCOON-1864
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Forms
>     Versions: 2.1.8, 2.1.9
>     Reporter: DennisDam
>     Assignee: Antonio Gallardo
>      Fix For: 2.2-dev (Current SVN), 2.1.10-dev (current SVN)

>
> I found a bug in the forms block of Cocoon 2.1.8 / 2.1.9. I found that 
> putting a min-size / initial-size attribute on a repeater element in the 
> CForms model, inverts the order of rows upon binding the form. So for 
> example the input document looked like:
> <document>
>   <row>a</row>
>   <row>b</row>
>   <row>c</row>
>   <row>d</row>
> </document>
> and my repeater model element's intial-size was set at 3. After 
> transforming the forms template with the forms transformer, I see the 
> following field instances (pseudocode):
> <field>c</field>
> <field>b</field>
> <field>a</field>
> <field>d</field>
> So what happens? The JXPathbinding for the repeater inverts the order of 
> the elements with index < initial-size! I traced this bug back to the 
> org.apache.cocoon.forms.binding.RepeaterJXPathBinding class, where I 
> found the following code snippet in the doLoad() method:
>             while (rowPointers.hasNext()) {
>                 // create a new row, take that as the frmModelSubContext
>                 Repeater.RepeaterRow thisRow;
>                 if (initialSize > 0) {
>                     thisRow = repeater.getRow(--initialSize);
>                 } else {
>                     thisRow = repeater.addRow();
>                 }
> I changed this into:
>         int currentRow = 0;
>         while (rowPointers.hasNext()) {
>             // create a new row, take that as the frmModelSubContext
>             Repeater.RepeaterRow thisRow;
>             if (currentRow < initialSize) {
>                 thisRow = repeater.getRow(currentRow++);
>             } else {
>                 thisRow = repeater.addRow();
>             }
> and now the binding works correctly / like I want it to work :). I must 
> note that I do NOT use an identity in my repeater binding declaration. 
> But I think it would be logical that leaving out the identity element 
> should result in preservation of the order the elements occur in the 
> input document.
> regards,
> Dennis Dam

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to