Thank you Cliff for looking at that “thing”:)
As I said, it is not a demo, it is just an application that I used for experimenting with different puremvc aspects, so please excuse the layout and the lack of comments in the code.
I will try to keep this post as short as possible. I explained more on the Google site (urls below) and made some diagrams.
There are 2 things going on:
1. The registration of Mediators for Views in a ViewStack.
2. A StateMachine for a form submission based on the PureMVC TV - FSM .
1. There isn't much to see, except for the messages coming from mediators (onRegister) – similar to the SlackerDemo. The difference between the SlackerDemo and my example consists in how I use the ChildExistenceChangedEvent and event.relatedObject to make the first View in the stack dispatch an event on creationComplete ( in order to register its Mediator)
You can see more details (explanation and diagram) here:
http://sites.google.com/site/mvc4flex/Home/deferred-instantiationor the entire code here:
http://code.google.com/p/ondina-air-flex-pmvc/source/browse/trunk/pureform/com/I don't know if this is a “clean” solution or not, but after trying to solve the issue of
deferred instantiation of views in a ViewStack and the registration of puremvc mediators in lots of ways, I decided to go with this one. I can't have a SplashView as in the SlackerDemo, meaning I can't have a View without a Mediator.
It would be nice if you could tell me if my solution is: very bad, bad, acceptable, good ...or if you'd give me some hints.
2. Now the StateMachine is the main reason I started the thread.
I took the FSM (Form Submission) from your presentation on PureMVC TV and modified it a bit.
http://sites.google.com/site/mvc4flex/Home/statemachineMy form consists of 5 input fields. The input fields are scattered over 3 Views, which probably was confusing.
OneView: user-firstname, user-lastname, user-phone
SubOneView: user-sex
SubTwoView: user-language.
This diagram may help understand the structure of my scattered input fields:
http://sites.google.com/site/mvc4flex/Home/the-formThe reason for having those scattered fields :
In my current project I have several views in some ViewStacks. Each View has several input fields. A View represents a certain category of information, let's say in one view I collect user's personal data , in another View data about user's relatives, in another view health related data e.t.c
There are 2 situations I have to deal with:
1 the data from all the Views has to be sent to the database, when the user hits the submit button
2 the data from a single View has to be saved separately
The Views have also their own VO.
In this example of mine I had only 5 input fields, just to keep it simple - in the beginning when I was trying to see how Notifications would work between different mediators.
Now the “happy path”:
The Form doesn't do much. A click on the submit form button takes the app from the COLLECTING state into the VALIDATING state.
If the form is valid , the data is sent to the proxy and eventually to the database( I couldn't do that on the Google Site of course ) and if everything went well the app goes into the THANKING state. If the form isn't valid (required fields still empty) a message about this fields appears in the middle of the app.The app is still in the VALIDATING state.
If you press the logout button while the app is still in the VALIDATING state, a confirm alert will appear asking if you want to quit.
The reset button empties the fields.
The StateMachine Notification are on the bottom of the page. I know, it looks a bit odd, because I wanted to see all the stuff going on on exiting, entering, changed....
So the StateMachine in my example seems to be working, but somehow I have the feeling that there is something I'm doing that is not quite right.
I tried to have the Validation happening on exiting from the COLLECTING state, as in your FSM. I could cancel the transition to the SAVING state, but then after a successful validation I couldn't take the app into the SAVING state. It seemed to me as if the app was in no state. I surely did something wrong.
So I decided to have an additional VALIDATING state instead of the exiting thing.
Now, I hope very much that my long post and the stuff on the Google site were comprehensible and you can take a look at the FSM and code and tell me your opinion about it.
Thank you again for your presentation on PureMVC TV. I hope to see more of the like...
Ondina