CHAPTER 11 (Web page design) REST-BASED MODEL VIEW CONTROLLER PATTERN
CHAPTER 11 REST-BASED MODEL VIEW CONTROLLER PATTERN tedious to maintain. Shown only with a basic amount of code is the validation of the data in the assignConfiguration method. Validating the data is good practice so that whenever local clients are instantiated, they are instantiated with valid values. The other method, buildCommands, adds local client-instantiated objects to the controller that can be executed whenever a request for execution happens. In the implementation of buildCommands, the method clearAllCommands removes all of the past instantiated Command instances. The old local client instances are cleared so that multiple threads do not use the same local client instances. The method addCommand is called to add the Amazon.com local client and Google local client instances to the controller. When the method buildCommands returns, the Parent interface instance contains a collection of Command implementations that can be called to perform some action and generate results. One last detail is to explain the implementations of the Result and Request interfaces, which are illustrated as follows: public class SearchRequest implements Request { private String _query; public SearchRequest( String query) { _query = query; } public String getQueryString() { return _query; } } public class SearchResult implements Result { String _url; String _title; String _snippet; String _transactionIdentifier; public SearchResult( String url, String title, String snippet, String transId) { _url = url; _title = title; _snippet = snippet; _transactionIdentifier = transId; } public String getTransactionIdentifier() { return _transactionIdentifier; } public String getURL() { return _url; } public String getTitle() { return _title; } public String getSnippet() { return _snippet; } }
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.