Hi all,
Just an update on #insert positioning logic. I have refactored it a
bit to be more consistent across the hierarchies:
AbstractContainer -> Form -> HtmlForm
AbstractContainer -> FieldSet -> HtmlFieldSet
When a control is inserted into a Container the specified insert index
will affect the Containers controls list. Previously the insert index
was inconsistent on Form as it changed the field position inside the
#fieldList instead of #controls list.
One remaining issue is that Form adds hidden fields to store its name
and submission token which can influence inserting. For example:
Form form = new Form("form"); // hidden field is created at position 0
form.add(new TextField("name")); // inserted at position 1
form.add(new TextField("score")); // inserted at position 2
Now user decides to insert new field "age" between field "name" and
"score":
int insertIndex = 1; // user thinks 1 is the correct index
form.insert(new TextField("age"), insertIndex);
However because of the hidden "form_name" field inserted by Form,
"age" ends up before "name" field.
One way of resolving this is to let Form declare variables for the
hidden fields instead of adding them to its #controls list. But at
this stage it might be too late to change for 1.5.
regards
bob