Personal web server - CHAPTER 9 STATE NAVIGATION PATTERN var StateController

CHAPTER 9 STATE NAVIGATION PATTERN var StateController = { username: null, password: null, postURL: null, constPageStateHeader : “X-Page-State”, constPageWindowName : “X-Page-Window-Name”, constPageOriginalURL : “X-Page-Original-URL”, constPageWindowNamePrefix : “StateController”, constResourceStateContentType : “application/xml”, constURLStateIdentifier : “/state”, constStateTag : “state”, constHtmlPageStateTag : “html-page”, StateController has nine data members, which all relate to sending and receiving data to and from the server. The data members username and password are the authentication identifiers used when accessing protected resources. The data member postURL indicates the URL used to post the data to the server. In a traditional HTML form, postURL would be the action attribute identifier. As an optimization, if an HTML form is serialized, the data member postURL is assigned the HTML form action attribute value. The remaining data members are used to dissect the communications between the client and server, and to generate and parse the XML data. Loading the State When the HTML page is loaded, the event onloadis triggered and causes the HTML state to be retrieved and added to the HTML page. The onload event is the usual place to put the state- loading functionality, but any other event could be used. Regardless of where the state-loading functionality is added, three functions are related to state loading: client implementation, default form loading, and overall controlling functionality. Following is the default client implementation: onLoadState : function( status, responseXML) { }, The method onLoadState, when it is not implemented by the HTML page, is an empty implementation that does nothing. In the example HTML page, the onLoadState method called the method loadForm, which is used as a prepackaged function to load the state of an HTML form. The method loadFormis implemented as follows: extractFormData : function( element, objData) { if( element.nodeType == 1) { if( element.nodeName == “form”) { objData.formId = element.attributes.getNamedItem( “id”).nodeValue; objData.formNode = document.forms[ objData.formId]; }
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply