Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: View State  (Read 5631 times)
Roustalski
Jr. Member
**
Posts: 13


View Profile Email
« on: March 27, 2009, 07:13:46 »

I have a composite component with a data grid in it with a few columns.

There is a new requirement for the user to be able to save the sort and order of the columns through logins. Classic user preferences.

What is the best way of going about persisting the state of the view?

More specifically, would there be anything wrong with storing some objects with the datafield/headertext in the appropriate order, and then in a command, build the columns dynamically from this list, which is then fed to the view via mediator?

Is there a better way?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 27, 2009, 07:53:55 »

Not a problem. Just as a form might send an event to its mediator saying it has domain data to send, a component with a grid could send an event saying the layout changed. Don't habve the mediator reach down into the component grabbing those props off the grid, though. That breaks the encapsulation of the component. Use a VO that the component populates with the values and the mediator grabs and hands off to a proxy for persistence. And visaversa, the proxy retrieves it, and sends it in a note to the mediator who sets it on the component. Internally you can apply those values by binding if you like, or by a method that does what you described, adding the columns to the grid.

Check the employee admin demo to see this happen with a user vo populatiing a form, etc. Check CodePeek and RSSReader which use DesktopCitizen to persist an AIR client's size and position info for some view state persistence juju.

-=Cliff>
Logged
Pages: [1]
Print