A couple of weeks ago, I announced that I have a component in the works that persists information on your forms. It also takes into consideration what user is using the application so that if you have a client/server app, a user gets the same user interface at any workstation. People who attended my ECO session at EKON even were able to see how it works and got some of the technical details.
This weekend, I wrapped it into a VCL.NET component which you can drop on your forms easily and thus persist all the information on the form (as content of edit boxes, width of grid columns) and about the form itself (size, position). The component also loads the model that is needed to persist the information completely on-the-fly, so that you can use it in any VCL.NET application without having to care about ECO! Here are some screenshots with details.
1. I created a new ECO VCL.NET application using the wizard. I selected Xml Persistence and did uncheck that a model is to be added to the project. The IDE presents me with the first form of the app. I select the component from the toolbar:
![]()
2. I add a couple of buttons and two edits. Mind, that the “Debug” button is not necessary. I use it to call the Eco Space debugger to find out if my component has been doing its job correctly. You will not need it.

3. Select the EcoPersistence component (displayed as a disk) and set the RootHandle to the only Root Handle there is on the form:

4. Compile.
5. Select the persistence package to be used by your application. Open the Eco Space by selecting it in the editor or by double clicking on EcoSpaceUnit.pas. If you are not familiar with ECO, this is really the “only” ECO-esque action you will have to do.
6. right click in the ECO Space and select “Select Packages”

Your dialog should look like that after you moved the package entry from the left to the right. If you see another package, move it to the left in case you are not interested in building an ECO application with more models and just want to use the persistence feature.
7. Select the filename for the data in case you want to persist the information after the application is being closed by selecting the “PersistenceMapperXml” and entering a filename. You can - of course - set the component using code as well.
8. Write code for the “Store” button:

9. The code for the “Restore” button is the same, just call the “restore” method.
10. If you want to persist the changes to the disk you have to call “FEcoSpace.UpdateDatabase” in your code as well. The name of the method is a bit confusing as Xml is not really a database, but you could persist the data to a database without any changes to your code, you simply need to drop a different persistence mapper on the ECO Space.
11. That’s it. If you have multiple forms in your application you only need to drop the component again and assign a RootHandle. All the other steps only have to be done once.
I realize you do not have the component set in hand yet. However, this example clearly shows that the possibilities with ECO and VCL.NET are infinite and with a little work you can get immensely complex things done. This example may seem trivial, but considering that you have separate data stored for different users already makes it complex. The ability to store into different storages as databases or flat files makes it even more intriguing.
Hopefully, my spare time will permit me to release this component set soon as I will be busy with other things next week.

No comments
Comments feed for this article
Trackback link
http://www.flickdotnet.de/index.php/2007/10/eco-toolset-taking-shape-persist-your-forms/trackback/