FLUID-3504: ChangeApplier has no convenient way to add items to an array in a model

Metadata

Source
FLUID-3504
Type
Improvement
Priority
Major
Status
Open
Resolution
N/A
Assignee
Antranig Basman
Reporter
Anastasia Cheetham
Created
2010-02-25T15:23:03.000-0500
Updated
2018-04-05T04:16:30.200-0400
Versions
  1. 1.1.2
  2. 2.0
Fixed Versions
N/A
Component
  1. Data Binder

Description

In cases where a model includes an array of some smaller objects, the ChangeApplier offers no convenient way to add several more of these smaller objects to that array all in one go. For example, if the form of the model includes

{
  things: [
    { thung: "foo" },
    { thung: "bar" }
  ]
}

If I wish to add three more 'thung's to 'things', I must fire three separate requests for a change, using the fully qualified EL path into 'things' i.e. using knowledge of how many 'thung's there already are:

applier.requestChange("things.2", newThungA);
  applier.requestChange("things.3", newThungB);
  applier.requestChange("things.4", newThungC);

It would be nice to be able to do it all in one request, so that only one modelChanged event is fired.

Comments

  • Anastasia Cheetham commented 2010-02-25T15:27:20.000-0500

    Alternatively, I could create a copy of the existing 'things', add my 'thung's to it, then request a single change on the whole thing... That doesn't seem entirely optimal either.

  • Antranig Basman commented 2014-10-30T18:16:50.775-0400

    In time, the ChangeApplier will be extended to support custom array insertion events as well as fixed to allow the DELETE operation to remove an array element. See IRC discussion in #fluid-work at https://botbot.me/freenode/fluid-work/2014-09-17/?msg=21823956&page=2