Scott Mebberson

Icon

Web Technologist

Editing VOs in the model?

We’re working on a Flex application at work, using Cairngorm, and we’re in the early architecting stages of the project.

We have a datagrid showing a list of clients (an ArrayCollection containing ClientVOs, which lives in model.clients).

We need to provide the functionality to edit a ClientVO, and save the data back to the database. When constructing the edit view we had to decide to either pass the ClientVO to the view by reference or to pass the ClientVO to the view by value.

The events we had to manage when exiting from the ClientVO edit view where:

  • Save. Save the ClientVO to the database, but do not exit the edit view.
  • Done. Save the ClientVO to the database and exit the edit view.
  • Cancel. Exit the edit view and discard any changes.

The Cancel event basically forced us to pass the ClientVO to the view by value, which gives you great flexibility on editing a local (to the edit view) version of the ClientVO.

However, it does mean you need to force the edited ClientVO back into model.clients (so that the datagrid contains the new values) at the correct index, effectively replacing the old version of the ClientVO and not an unrelated ClientVO.

I’m not sure if there is a Design Pattern that supports this, or demonstrates how to handle this better.


Filed under: cairngorm, flash platform, flex

Leave a Reply