Closed Bug 334015 Opened 18 years ago Closed 18 years ago

repeat index() doesn't reset to 0 when last repeat item is deleted

Categories

(Core Graveyard :: XForms, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: sspeiche, Assigned: allan)

References

()

Details

(Keywords: fixed1.8.0.5, fixed1.8.1)

Attachments

(4 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060411 Firefox/3.0a1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060411 Firefox/3.0a1

1.0 2ed test suite case 9.3.6.a shows a index() == 1 when
all repeat items have been removed (when it should be == 0)

See related bug 282828

Reproducible: Always
Attached file testcase
Status: UNCONFIRMED → NEW
Ever confirmed: true
Blocks: 322255
Blocks: 331209
An output that uses @value="index('repeater')" currently isn't guarenteed to have the correct value.

Looks like the problem is that output evaluates the xpath during ::Bind (though not displayed until ::Refresh) and repeat doesn't set index until its ::Refresh.  But even if output evaluated it at refresh, it still might not be right, depending if its refresh was before repeats or not.

Seems like something for the xpath dependency stuff.  Otherwise a hack would be that any control who asks for index() should get registered with the repeat somehow?  Yuck.  I don't think that would be easy to keep that hack on the XForms side of the fence w/o doing string parsing.  And it isn't just controls, also xf:bind.

I don't know if this is related to the other index bugs.  Didn't seem like it when I read the other abstracts.  For what it is worth, the repeat index seems to be right.
Attached file testcase 2
This testcase also shows the problem.  Notice that adding items seems ok, but then deleting items will always have index showing as 1 off.  Again, the index is right on the repeat by the time its refresh method returns.  But since the output asked for the index before repeat had changed it, the value the user sees is wrong.
Attachment #220090 - Attachment mime type: text/html → application/xhtml+xml
(In reply to comment #2)
> Seems like something for the xpath dependency stuff.  Otherwise a hack would be
> that any control who asks for index() should get registered with the repeat
> somehow?  Yuck.  I don't think that would be easy to keep that hack on the
> XForms side of the fence w/o doing string parsing.

It is yuck, but it is unavoidable, and we have it already. It is not handled by the MDG, because the index is this "magic thing" hanging around without being bound to the instance data. The same goes for switch state. There are probably amplications, but they should possibly have been done like instance('internal')/repeat_index/<id> and instance('internal')/swith_state/<id>

> And it isn't just controls, also xf:bind.

Bug 292333.

The problem is probably that the IndexHasChanged() code is not run when index reached zero. /me wonders it this is fixed by bug 331452.
Assignee: aaronr → allan
Status: NEW → ASSIGNED
OS: Windows XP → All
Hardware: PC → All
There seems to be generic index problems. Probably regressed from bug 331452.
Related problem showing up, when we actually manage to get index to be 0.
Attached patch Patch (obsolete) — Splinter Review
Also fixes the setindex problem (testcase in attachment 223013 [details]).
Attachment #223014 - Flags: review?(Olli.Pettay)
Comment on attachment 223014 [details] [diff] [review]
Patch

I think I have a better patch coming up, which also takes care of bug 318779 too.
Attachment #223014 - Attachment is obsolete: true
Attachment #223014 - Flags: review?(Olli.Pettay)
Attached patch PatchSplinter Review
Problems were that I forgot to handle the empty nodeset case, and that I forgot to inform about index changes on all cases.

(the main problem is that the code is awful, but I do not have time to rewrite it, as it should be... :( )
Attachment #223027 - Flags: review?(Olli.Pettay)
Comment on attachment 223027 [details] [diff] [review]
Patch

r=me, I think :)
Attachment #223027 - Flags: review?(Olli.Pettay) → review+
Attachment #223027 - Flags: review?(aaronr)
Attachment #223027 - Flags: review?(aaronr) → review+
Fixed on trunk
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Whiteboard: xf-to-branch
Blocks: 318779
Keywords: fixed1.8.1
Keywords: fixed1.8.0.5
Whiteboard: xf-to-branch
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: