284 CHAPTER 9 STATE NAVIGATION PATTERN it as being some text in an HTML div section. It is the responsibility of the HTML methods onSaveStateand onLoadState to load and save the data. In the HTML page implementation, the methods onSaveStateand onLoadState could be construed as black magic in that they generate and process data without explaining what the data is. What happens is that the data generated and processed by the HTML page is a blob that is sent and received from the server. Only the client needs to know what the data is, and not the State Navigation implementation. In the example, the variable StateController uses XML persistence as a default persistence format. As a result, when the client uses the standard method calls saveFormand loadForm, the generated data is XML based and would be identical to the following:
The root node is data, and contained within it is the HTML state that includes reference information about the state, and the state information associated with the HTML page. Specifically, the individual XML tags are identified as follows: html-page: Is a parent XML element used to contain the state details associated with an HTML page. form: Is a parent XML element used to contain the values for all HTML form elements. element: Identifies a state that is associated with an HTML form element. In the example, all HTML form elements are associated with the XML tag element. But it is also possible to use the id attribute as an XML element identifier. This results in the transformation
for the XML element with the attribute value param1. Which approach you use depends on your preference; either approach is acceptable. For consistency, the state that is sent is identical to the state that is received. The Details of the State Navigation StateController is a variable instance and a custom single kind of a type. StateController could have been defined as a type that is instantiated, but that would be adding unnecessary complexity. As I am explaining the technical details of StateController, I won t explain all of the code at once. What I will explain is the source code in three pieces: the first piece contains the data members, the second piece contains the logic used to load the state, and the last piece contains the logic to save the state. Following is the code piece that defines the data members of the StateController variable:
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.
This entry was posted
on Friday, November 16th, 2007 at 8:16 pm and is filed under Coldfusion.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.