Analysis of Ajax webshop dataset and dbcontrol data sensing mechanisms

Source: Internet
Author: User

Analysis of Ajax webshop DatasetAnd dbcontrolData sensing mechanism

Implementation PrincipleBy registering the data Sensor Object List, all registered data sensor objects are notified when a corresponding event occurs in dataset. When a data Sensor Object receives a notification, it is notified Based on the message number and data, for example, refresh and display.Message numberModify: 12 open: 0 Refresh: 5 close: 7 move record: 3 append: 1 Delete: 2 firedatachange: 6 post: 13 cancel: 9 apply: 8 fieldvalue firechange: 4 notify lookup Dataset: 11Program AnalysisTake dbedit as an example. First, dbedit sets the property dataset or setdataset and calls linkobj to register dbedit to the data Sensor Object List. This list is actually an array. When a dataset event occurs, call notify to notify all objects in the Data Sensor Object List, and all data sensor objects have an interface to implement handlemessage, which is called in dataset. Let's take a look at notify's implementation:

Dataset. Prototype. Y = function (Act, recno, p) {var OS = This. linkobjs; If (! OS | this. autocontrol = false) return; For (var j = 0; j <OS. length; j ++) if (OS [J]. handlemessage) OS [J]. handlemessage (this, act, recno, P );}
Then let's take a look at what dbedit's handlemessage has done. See the following implementation. It's nothing more than refreshing the display data.
Function dc_handlemessage (sender, MSG, recno) {If (MSG! = 6 & MSG! = 12) This. refresh ();} function dc_refresh () {var V, F; If (this. dataset. active) {f = This. dataset. fields. field [this. datafield]; If (! F) jcl_err (this. name + '. datafield: '+ this. datafield + err_nofield); If (f) {This. readonly = f. readonly; V = f. getvalue (); If (V = NULL) V = ''; this. value = V; If (this. type = 'span ') This. innerhtml = V; // dblabel if (this. type = 'checkbox') {If (this. checkedvalue = V) {This. checked = true; this. defaultchecked = true;} else {This. checked = false ;}}} else {This. value = ''; If (this. type = 'span ') This. innerhtml = ''; // dblabel }}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.