I have a simple data grid populated from an ArrayCollection
On the same screen, a simple custom component is bound to
Initially my form shows blank, clicking an item in the grid
populates the form.
Now I need to have the ability to remove the selected item
form the list.
using myCollection.removeItemAt() removes the item from the
collection OK but an exception is raised due to the form now being
bound to a non-existing object:
Cannot access a property or method of a null object reference
De-selecting the item in the grid instead of removing from
the collection has the same effect, even though in its initial
state when no item is selected there isn't a problem, the form is
I tried binding the form to a public variable in my
controller class and setting that variable on myDataGrid.change.
Binding works that way but I still get an error when removing or
de-selecting the item.
Is there a way I can go back to this initial state of the
form being blank when the object its bound to is null/undefined/not
It seems like since it lets you bind to selectedItem before
one is selected, it makes sense that you'd be able to de-select it
and the binding not break.
Thanks for the reply. I thought such a workaround would be
Perhaps a tidier way would be to bind the form to another
object in my controller class and set that to a blank object when
removing or de-selecting an item. When an item is selected, that
object is set to the datagrid's selectedItem. That way I'd not need
to add extra code to my form.