SetIndex to bottom of Repeat list fails

Project:formsPlayer
Version:1.6.1029-dev
Component:Miscellaneous
Category:bug
Priority:critical
Assigned:Unassigned
Status:closed
Description

This issue is the one Paul has been working on over that last little while
When we add an item to a Repeat list using duplicate we try to set the index to the new element at the bottom of the list.
The element that receives the highlight is the one second from the bottom.
A 'Save' button tied to a 'dirty' flag appears when we add the element however, ancillary to that, any other changes on the form causes the 'dirty' flag to be reset.

Updates

#1 submitted by Paul Butcher on Thu, 2008-02-14 17:29
Status:new» applied

The issue with the save button has been resolved in the newest release, (1.6.1011). In the process of populating the grid repeat, the content of the setvalue that maintained the "dirty" status was being lost.

The issue with setindex is by design. Since the earliest 1.5 versions, the deferred update concept has been universal, rather than invoked by the bounds of an action element. As such, when the setindex is called, the dependencies have not yet been rebuilt, and there are still only 5 profiles in the repeat, so the index is set to the fifth, following a rebuild, there are now 6, but the 5th is still the index.

In order to fix this, where the "Add..." trigger contains code in the form


<xf:action ev:event="DOMActivate">
  <xforms:duplicate ref="instance('Configuration')/ItemProcessing/TransactionProfiles" origin="instance('Template2')" />
...
</xf:action>
<xforms:setindex repeat="rpt-transaction-profile" index="999"  ev:event="DOMActivate" />

Should be changed to


<xforms:action ev:event="DOMActivate">
	<xforms:duplicate ref="instance('Configuration')/ItemProcessing/TransactionProfiles" origin="instance('Template2')" />
	<xforms:rebuild />
	<xforms:setindex repeat="rpt-transaction-profile" index="999" />
</xforms:action>

The manual rebuild will ensure that rpt-transation-profile is up-to-date when setindex is called.

#2 submitted by Paul Butcher on Thu, 2008-02-14 19:15

Actually, I'm wrong about the behaviour of setindex and rebuild, here. The latest version of the spec mandates an implicit rebuild as part of the invocation of setindex. This is a very easy fix, which I have applied to 1.6.1012, which will be available as quickly as I can upload it.

#3 submitted by fmcgovern on Fri, 2008-02-15 15:10
Status:applied» closed

Verified fixed in version 1.6.1012.0