CN104407863B - Abstract control model programmer and method - Google Patents
Abstract control model programmer and method Download PDFInfo
- Publication number
- CN104407863B CN104407863B CN201410671291.7A CN201410671291A CN104407863B CN 104407863 B CN104407863 B CN 104407863B CN 201410671291 A CN201410671291 A CN 201410671291A CN 104407863 B CN104407863 B CN 104407863B
- Authority
- CN
- China
- Prior art keywords
- control
- abstract
- primary
- programming
- html
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Abstract
The invention provides a kind of abstract control model programmer, including:Abstract package unit, to the abstract package of primary control, abstract control programming is carried out for using abstract control model;Data communication unit, after terminating for the programming of abstract control, carries out the data communication between abstract control and primary control.Present invention also offers a kind of abstract control model programmed method.By technical scheme, can be on the basis of existing model programming mode, the model for making full use of conventional object type to complete abstract object type is programmed, and sets up general, the unified program thread towards abstract control model programming mould that many object types are participated in.
Description
Technical field
The present invention relates to field of computer technology, in particular it relates to which a kind of abstract control model programmer and one kind are taken out
As control model programmed method.
Background technology
Different operating systems are there are in Mobile Development field.Software developer must not be in different movements
Repeat exploitation between operating system and mobile device in order to compatible.It is flat for different operations in traditional exploitation
Platform, will develop different applications using different language and developing instrument.For example:Exploitation one can be operated on IOS
Mobile solution, developer is generally accomplished by using Object-C language to carry out coding exploitation, it is corresponding the need for
Mobile solution on Android operation system is accomplished by developer and is entered according to Android development schemes using Java language
Row exploitation.The differentiation of operation platform is bigger, develops a cost for running on the application software on multiple platforms higher.
In Mobile Development, the programming to control is most common, most basic programming mode.But each mobile platform
Control miscellaneous is provided to developer, developer just needs in order to be able to develop the APP operated on different mobile platforms
Learn to use various control systems, and each platform control API to be also not quite similar.If can have standard set control mould
Type, will be an extremely significant thing by the long-cherished wish that this set of control model is achievable cross-platform programming.
Since being born from internet, web technology with HTML as representative seems to have become by forging for many years with baptism
Must be rooted in the hearts of the people, in recent years the emergence of HTML5, there is the gesture of dominance greatly.The application developed using HTML5 can be
Run on major cell phone platforms such as ios, android, blackberry, with cross-platform advantage.But HTML5 is in such as property
The aspect such as energy, smoothness, Consumer's Experience also has unsatisfactory place, has natural gap with native applications.
Accordingly, it would be desirable to which a kind of new model programming technique, can make full use of on the basis of existing model programming mode
Conventional object type completes the model programming of abstract object type, sets up being compiled towards abstract control model for many object types participations
Cheng Mo general, unified program thread.
The content of the invention
The present invention is based on above mentioned problem, it is proposed that a kind of new model programming technique, can be compiled in existing model
On the basis of journey mode, the model for making full use of conventional object type to complete abstract object type is programmed, and sets up many object type ginsengs
With towards abstract control model program general, unified thinking.
In view of this, the present invention proposes a kind of abstract control model programmer, including:Abstract package unit, is used for
Using abstract control model to the abstract package of primary control, abstract control programming is carried out;Data communication unit, for abstract control
After part programming terminates, the data communication between abstract control and primary control is carried out., can be by abstract in the technical scheme
Control programming, easily accesses the primary control of operation, shields the differentiation of different mobile platforms, realizes Cross-border congestion management.
In the above-mentioned technical solutions, it is preferable that the abstract package unit, specifically include:DOM Document Object Model (DOM) is taken out
As control and the genetic module of programming mode, for regarding a primary page as a HTML (HyperText Mark-up
Language, is a kind of standard language for making World Wide Web page) page, each primary control in the primary page is abstracted into
One element (Element) object;By document in JavaScript (JavaScript be belong to network script)
(document) object (html document of each loading browsers can turn into Document objects) uses the mode of DOM objects
Realize the access and operation to each control in HTML;Abstract control model generation module, for by primary control HTML
To define, and (JavaScript Object Notation are a kind of lightweights using the JSON in Javascript language
Data interchange format) object describes the corresponding DOM objects of this HTML;Abstract control model programming and application programming connect
Mouthful (Application Programming Interface, API) module, for use for reference HTML DOM programming mode there is provided
$ document objects and API of the same name, complete abstract control programming;After the completion of abstract control programming, based on HTML DOM programmings,
Abstract control is read out using API, access, operated.In the technical scheme, can be provided by the control model
HTML DOM API and programming mode, the API provided by the abstract control model is come opening of shielding that different mobile platforms bring
The otherness of hair, easily realizes cross-platform programming, reduces the learning cost of developer, so as to reduce cross-platform Mobile Development door
Sill.
In the above-mentioned technical solutions, it is preferable that the abstract control model generation module describes the JSON of DOM objects
(JavaScript Object Notation are a kind of data interchange formats of lightweight), the unique mark id comprising control,
The tag labels of corresponding HTML, represented using the base attribute of HTML element primary control attribute json objects, one
State descriptors and container control of the abstract control object in control tree describe its child control information by children
Array;And/or, the $ document objects that the abstract control model programming and API module are provided, are a Document classes
The singleton object of type, any one abstract control is able to access that by it.
In the above-mentioned technical solutions, it is preferable that before the abstract package unit carries out the operation of abstract control programming, also
Including:The UI information of HTML5 and primary control is combined, refinement obtains the abstract control model based on JavaScript.At this
In technical scheme, developer only needs to can control different shiftings by the abstract control model of this set using JavaScript language
Primary control on moving platform, can play primary APP【Application program (abridge by foreign language:App, foreign language full name:
Application)】Inherent advantage in terms of user interface (User Interface, UI), can use JavaScript again
Language solves the problems, such as cross-platform programming.
In the above-mentioned technical solutions, it is preferable that the data communication unit, specifically include:Primary calling module, for working as
After the programming of abstract control terminates, perform and initiated after a method by JS (JavaScript be belong to network script) end
One primary to be called, and the corresponding JSON data of abstract control are supplied into primary end main thread;The operation of primary control and renewal
Module, after receiving this part of JSON data for primary end main thread, each abstract control in JSON data is retouched
Information is stated, the code for updating primary UI controls is performed, so as to complete the operation to primary control and renewal.In the technical scheme
In, the characteristics of using JavaScript language and DOM Document Object Model (DOM) in HTML technologies, propose a set of to be compiled based on DOM
Cheng Fengge abstract control model.Developer only need to be directed to the abstract control model first encoding of this set using JavaScript,
It can just support to run on different operation platforms.
According to a further aspect of the invention, it is also proposed that a kind of abstract control model programmed method, including:Step 202:
Using abstract package of the abstract control model to primary control, abstract control programming is carried out;Step 204:Abstract control programming knot
Shu Hou, carries out the data communication between abstract control and primary control.In the technical scheme, can be compiled by abstract control
Journey, easily accesses the primary control of operation, shields the differentiation of different mobile platforms, realizes Cross-border congestion management.
In the above-mentioned technical solutions, it is preferable that the step 202, specifically include:Step 302:One primary page is seen
Work is a html page, and each primary control in the primary page is abstracted into an Element object;In JavaScript
In realize to HTML by way of document objects are using DOM objects in each control access with operation;Step
304:Primary control is defined with HTML, and this HTML correspondences are described using the JSON objects in Javascript language
DOM objects;Step 306:HTML DOM programming mode is used for reference there is provided $ document objects and API of the same name, is completed abstract
Control is programmed;After the completion of abstract control programming, based on HTML DOM programmings, abstract control is read out using API, is accessed,
Operation.In the technical scheme, the HTML DOM API and programming mode that can be provided by the control model are abstract by this
The API that control model is provided shields the otherness of the exploitation that different mobile platforms bring, and easily realizes cross-platform programming, reduces
The learning cost of developer, so as to reduce cross-platform Mobile Development threshold.
In the above-mentioned technical solutions, it is preferable that the step 304 describes the JSON of DOM objects, unique mark comprising control
Know id, the tag labels of corresponding HTML, json pairs of attribute of primary control is represented using the base attribute of HTML element
As, the state descriptors and container control of abstract control object in control tree describe its child control by children
The array of information;And/or, the $ document objects that the step 306 is provided, are a singleton objects for Document types,
Any one abstract control is able to access that by it.
In the above-mentioned technical solutions, it is preferable that the step 202 is carried out before the operation of abstract control programming, is also included:
The UI information of HTML5 and primary control is combined, refinement obtains the abstract control model based on JavaScript.In the technical side
In case, developer only needs to can control different mobile platforms by the abstract control model of this set using JavaScript language
On primary control, inherent advantages of the primary APP in terms of UI can be played, JavaScript language can be used again to solve
The problem of cross-platform programming.
In the above-mentioned technical solutions, it is preferable that the step 204, specifically include:Step 402:Tied when abstract control is programmed
Shu Hou, initiation one is primary after JS ends perform a method is called, and the corresponding JSON data of abstract control are supplied into original
Cause trouble main thread;Step 404:After primary end main thread receives this part of JSON data, each in JSON data is taken out
As the description information of control, the code for updating primary UI controls is performed, so as to complete operation and renewal to primary control.At this
In technical scheme, the characteristics of using the JavaScript language in HTML technologies and DOM Document Object Model (DOM), a set of base is proposed
In the abstract control model of DOM coding styles.Developer only need to be directed to the abstract control model one of this set using JavaScript
Secondary coding, can just support to run on different operation platforms.
By above technical scheme, conventional object type can be made full use of on the basis of existing model programming mode
Complete the model programming of abstract object type, set up that many object types participate in towards abstract control model programming mould it is general,
Unified program thread.
Brief description of the drawings
Fig. 1 shows the block diagram of control model programmer abstract according to an embodiment of the invention;
Fig. 2 shows the flow chart of control model programmed method abstract according to an embodiment of the invention;
Fig. 3 shows the flow chart of abstract package unit according to an embodiment of the invention;
Fig. 4 shows the flow chart of data communication unit according to an embodiment of the invention;
Fig. 5 shows the schematic diagram of the evolution of the abstract controls of DOM according to an embodiment of the invention and programming mode.
Fig. 6 shows the flow chart of the evolution of the abstract controls of DOM according to an embodiment of the invention and programming mode.
Fig. 7 shows the flow chart of the abstraction process of control model abstract according to an embodiment of the invention.
Fig. 8 shows the flow chart for obtaining an abstract control specified attribute according to an embodiment of the invention.
Fig. 9 shows one flow chart of abstract control specified attribute of setting according to an embodiment of the invention.
Figure 10 and Figure 11 respectively illustrate Element objects according to an embodiment of the invention have setAttribute and
Two flow charts of conventional method of getAttribute;
Figure 12 shows the data communication between control model abstract according to an embodiment of the invention and primary control
Flow chart.
Specific embodiment
It is below in conjunction with the accompanying drawings and specific real in order to be more clearly understood that the above objects, features and advantages of the present invention
Mode is applied to be further described in detail the present invention.It should be noted that in the case where not conflicting, the implementation of the application
Feature in example and embodiment can be mutually combined.
Many details are elaborated in the following description in order to fully understand the present invention, but, the present invention may be used also
Implemented with being different from other modes described here using other, therefore, protection scope of the present invention is not by described below
Specific embodiment limitation.
Fig. 1 shows the block diagram of control model programmer abstract according to an embodiment of the invention.
As shown in figure 1, control model programmer 100 abstract according to an embodiment of the invention, including:Abstract package list
Unit 102, to the abstract package of primary control, abstract control programming is carried out for using abstract control model;Data communication unit
104, after terminating for the programming of abstract control, carry out the data communication between abstract control and primary control.In the technical scheme
In, can be programmed by abstract control, the primary control of operation is easily accessed, the differentiation of different mobile platforms is shielded, realize
Cross-border congestion management.
In the above-mentioned technical solutions, it is preferable that abstract package unit 102, specifically include:The abstract controls of DOM and programming side
The genetic module 1022 of formula, for regarding a primary page as a html page, by each is primary in the primary page
Control is abstracted into an Element object;Realized by way of document objects are using DOM objects in JavaScript
Access and operation to each control in HTML;Abstract control model generation module 1024, for by primary control HTML
To define, and the corresponding DOM objects of this HTML are described using the JSON objects in Javascript language;Abstract control mould
Type is programmed and API module 1026, and the programming mode for using for reference HTML DOM, there is provided $ document objects and API of the same name is complete
Into the programming of abstract control;After the completion of abstract control programming, based on HTML DOM programmings, abstract control is read out using API,
Access, operate.In the technical scheme, the HTML DOM API and programming mode that can be provided by the control model are passed through
API that the abstract control model is provided shields the otherness for the exploitation that different mobile platforms are brought, and easily realizes cross-platform volume
Journey, reduces the learning cost of developer, so as to reduce cross-platform Mobile Development threshold.
In the above-mentioned technical solutions, it is preferable that abstract control model generation module 1024 describes the JSON of DOM objects, wrap
The tag labels of unique mark id, corresponding HTML containing control, primary control is represented using the base attribute of HTML element
State descriptors in control tree of the json objects of attribute, abstract control object and container control by children come
The array of its child control information is described;And/or, the $ document couple that abstract control model programming and API module 1026 are provided
As being the singleton object of a Document type, any one abstract control being able to access that by it.
In the above-mentioned technical solutions, it is preferable that before abstract package unit 102 carries out the operation of abstract control programming, also
Including:The UI information of HTML5 and primary control is combined, refinement obtains the abstract control model based on JavaScript.At this
In technical scheme, developer only needs to can control different shiftings by the abstract control model of this set using JavaScript language
Primary control on moving platform, can play inherent advantages of the primary APP in terms of UI, and JavaScript language can be used again
To solve the problems, such as cross-platform programming.
In the above-mentioned technical solutions, it is preferable that data communication unit 104, specifically include:Primary calling module 1042, uses
In after the programming of abstract control terminates, called by the way that initiation one is primary after one method of JS ends execution, by abstract control correspondence
JSON data be supplied to primary end main thread;The operation of primary control and update module 1044, connect for primary end main thread
After this part of JSON data, the description information of each abstract control in JSON data performs and updates primary UI controls
The code of part, so as to complete operation and renewal to primary control.In the technical scheme, using in HTML technologies
The characteristics of JavaScript language and DOM Document Object Model (DOM), propose a set of abstract control mould based on DOM coding styles
Type.Developer only need to be directed to the abstract control model first encoding of this set using JavaScript, can just support in different operations
Run on platform.
Fig. 2 shows the flow chart of control model programmed method abstract according to an embodiment of the invention.
As shown in Fig. 2 control model programmed method abstract according to an embodiment of the invention, including:Step 202:Utilize
Abstract control model carries out abstract control programming to the abstract package of primary control;Step 204:After abstract control programming terminates,
Carry out the data communication between abstract control and primary control.In the technical scheme, it can be programmed by abstract control, it is convenient
Ground accesses the primary control of operation, shields the differentiation of different mobile platforms, realizes Cross-border congestion management.
In the above-mentioned technical solutions, it is preferable that as shown in figure 3, step 202, specifically includes:Step 302:It is primary by one
The page regards a html page as, and each primary control in the primary page is abstracted into an Element object;
The access of each control and behaviour in being realized in JavaScript by way of document objects are using DOM objects to HTML
Make;Step 304:Primary control is defined with HTML, and this is described using the JSON objects in Javascript language
The corresponding DOM objects of HTML;Step 306:Use for reference the programming mode of HTML DOM, there is provided $ document objects and API of the same name,
Complete abstract control programming;After the completion of abstract control programming, based on HTML DOM programmings, abstract control is read using API
Take, access, operate.In the technical scheme, the HTML DOM API and programming mode that can be provided by the control model lead to
Cross the API of abstract control model offer to shield the otherness of the exploitation that different mobile platforms bring, easily realize cross-platform
Programming, reduces the learning cost of developer, so as to reduce cross-platform Mobile Development threshold.
In the above-mentioned technical solutions, it is preferable that step 304 describes the JSON of DOM objects, the unique mark comprising control
Id, the tag labels of corresponding HTML, represented using the base attribute of HTML element primary control attribute json objects,
The state descriptors and container control of one abstract control object in control tree describe its child control letter by children
The array of breath;And/or, the $ document objects that step 306 is provided, are a singleton objects for Document types, by it
It is able to access that any one abstract control.
In the above-mentioned technical solutions, it is preferable that before step 202 carries out the operation of abstract control programming, also include:Will
The UI information of HTML5 and primary control is combined, and refinement obtains the abstract control model based on JavaScript.In the technical scheme
In, developer only needs to be can control on different mobile platforms by the abstract control model of this set using JavaScript language
Primary control, inherent advantages of the primary APP in terms of UI can be played, JavaScript language can be used again come solve across
The problem of platform is programmed.
In the above-mentioned technical solutions, it is preferable that as shown in figure 4, step 204, specifically includes:Step 402:When abstract control
After programming terminates, initiation one is primary after JS ends perform a method is called, and the corresponding JSON data of abstract control are carried
Supply primary end main thread;Step 404:It is every in JSON data after primary end main thread receives this part of JSON data
One description information of abstract control, performs the code for updating primary UI controls, thus complete to the operation of primary control with more
Newly.In the technical scheme, the characteristics of using the JavaScript language in HTML technologies and DOM Document Object Model (DOM), carry
Go out a set of abstract control model based on DOM coding styles.Developer need to only use JavaScript to be directed to the abstract control of this set
Part model first encoding, can just support to run on different operation platforms.
Technical scheme, is based on the cross-platform abstract control modelling technique solution of movement.It is of the invention
Technical scheme, is related to the present situation of the different development language of different control model needs in Mobile Development field, proposes a set of system
The one abstract control model realized based on JavaScript language, the HTML DOM API provided by the control model and volume
Journey mode, can easily access the primary control of operation;So as to shield the differentiation of different mobile platforms, so as to realize cross-platform
Exploitation.
In order to be able to carry out Cross-border congestion management, the inherent advantage of primary control is also kept, we are by HTML5 and primary control
Advantage in terms of UI combines, and extracts a set of abstract control model based on JavaScript, and developer only needs to
Using JavaScript language by the abstract control model of this set be can control different mobile platforms on primary control.So both
Inherent advantages of the primary APP in terms of UI can be played, JavaScript language can be used to solve asking for cross-platform programming again
Topic.
Technical scheme, it is intended to for Mobile Development field uses a set of the taking out based on JavaScript language of offer
As control programming model, the difference for the exploitation that different mobile platforms are brought is shielded by the API of abstract control model offer
Property, cross-platform programming is easily realized, the learning cost of developer is reduced, so as to reduce cross-platform Mobile Development threshold.
The characteristics of we use JavaScript language and DOM Document Object Model (DOM) in HTML technologies, proposes a set of
Abstract control model based on DOM coding styles.Developer only need to be directed to the abstract control model of this set using JavaScript
First encoding, can just support to be run on different operation platforms, the difference of control programming on platform need not be comprehended completely, gently
Loosely realize the cross-platform Mobile Development dreamed of.
In order to be able to realize above-mentioned target, it is necessary to solve following several things:
Firstth, cross-platform programming is solved using JavaScript language.
Secondth, cross-platform control programming is realized using abstract control model.
3rd, how abstract control carries out abstract to primary control.
4th, the data communication between the how primary control of abstract control.
The all respective JS engines of different mobile platforms, such as Android has V8 engines, and IOS has JavaScript Core to draw
Hold up, add mobile platform offer webview components can be very good to realize it is mutual between primary language and JavaScript
Call, so the problem of can just solving cross-platform programming language from JavaScript language.
We describe an abstract control, all programmings to control using the JSON objects in JavaScript language
The programming to JSON objects is converted into, different language is so needed to use originally to primary control could be operated by different API,
And need only to operate JSON using JavaScript language now.
Next, our emphasis are illustratedHow to realize abstract control model to the abstract package of primary control and abstract Data communication between control and primary control:
1st, the evolution of the abstract controls of DOM and programming mode
It is well known that in HTML, realizing the access ability to HTML by DOM, and developer is made HTML
Handle and check for XML document.Can access and control using document and HTML Element in JavaScript
All elements in html page.
This thought is incorporated into Mobile Development field by we, and we can regard a primary page as a HTML
The page, then each primary control can be abstracted into an Element object in the page.Can be with JavaScript
Come the access of each control in realizing to HTML and operated by way of DOM objects document objects.We make
Such a DOM objects are defined with the JSON objects in JavaScript, and a $ document object is provided, by $
Document also can be as using document, conducting interviews and operating to all abstract controls on current page.Referring to figure
5。
Its evolutionary process is referring to Fig. 6.
2nd, abstract control model
We combine the thought of HTML and DOM, primary control (Android or IOS controls) are defined with HTML, and make
The corresponding DOM objects of this HTML are described with the JSON objects in Javascript language, the JSON includes following content:
id:The id of control, unique sign of control.
tag:The tag labels of corresponding HTML.
attrs:One json object, the attribute of primary control is represented using the base attribute of HTML element.
status:For describing the state of abstract control object in control tree, have add, modified,
The states such as delete, insert.
children:It is an array, a container control describes its child control information by children.
Now this JSON object can also be regarded as one " control " by we, and only this control compares " special
Very ", it is one to the abstract of primary control.
Such as in Android edit box control EditText, its text is " abc ", usually fixed with input units in HTML
Justice is:
<Input id=" textbox0 " type=" text " value=" abc "/>
We are described as a JavaScript JSON object with abstract control:
Its abstraction process is as shown in Figure 7.
With the abstract evolution of control, its corresponding programming mode is also converted into JavaScript by the programming of primary control
Programming mode.
Global variable $ docuemtn, for representing to whole abstract control model object, its storage inside one
The json objects of JavaScript, for describing current abstract control tree.This JSON pairs as if a sky JSON object when initial,
When being operated with being conducted interviews to specified abstract control in code, the increase that $ document objects can dynamically progressively is corresponding
Control description.This is also to be abstract control why.Because basic in $ document objects when incipient
There is no JSON controls.
The getElementById methods of $ document objects, return to an Element object.
There is a json object to be used for all information for describing the abstract control inside Element objects, and provide
SetAttribute and getAttribute methods are used for setting or obtaining json object's property values, i.e., the attribute of abstract control
Value.
The process for obtaining an abstract control specified attribute is as shown in Figure 8.
The process for setting an abstract control specified attribute is as shown in Figure 9.
For example, inside $ document be empty object, i.e. { } for abstract control JSON when initial,
After one section of JS code is performed, the JSON objects become
3rd, abstract control model programming and API
In the programming of abstract control, the programming mode of HTML DOM has been used for reference, there is provided $ document objects and of the same name
API, document pair as if a singleton object for Document types, by it has access to that arriving any one abstract control
Part.
The developer for being familiar with HTML DOM programmings will be readily appreciated that and abstract control is read out using API, is visited
Ask, operate.
The object of the global unique Document types of $ document objects, can using getElementById methods
To return to an Element object.
Element objects have two conventional methods of setAttribute and getAttribute.Such as Figure 10 and Figure 11 institutes
Show.
We explain the code presentation process of abstract control programming below.
For example:There is text edit box control in Android and IOS, we are lifted by the way of the programming of abstract control
Example illustrates how to carry out value assignment operation to defining a text box, and to this text box.
First, the use HTML definition of a text box is as follows:
<Input id=" text " textbox0 " type=" text " value=" 123 "/>
Now the corresponding abstract control model of text frame control can be described as
When now we need the value of an abstract control of input frame to change into " abc " by " 123 ", i.e., corresponding HTML
For
<Input id=" textbox0 " type=" text " value=" abc "/>
It is as follows using the abstract control programming codes of JS:
Var tb0=$ document.getElemtnById (" textbox0 ");// according to id automatically create one it is abstract
Control object is simultaneously returned
tb0.setAttribute("value","abc");// set the Element objects inside JSON objects in
The value of attrs is character string " abc "
Var val=tb0.getAttribute (" value ");In the JSON objects of // return Element objects inside
The value of attrs value attributes
Now JSON structures are as follows
GetElementById in first code is identical with the getElementById implications that HTML DOM are programmed
It is to obtain a DOM object, difference is that can remove in DOM to find Element objects according to parameter id in HTML, and
It is at all without this Element object in abstract control programming, that is to say, that document objects are a skies at the beginning
Object { }, can one id of dynamic creation be in $ document when the getElemtntById methods of $ domcument are called
The json objects of textbox0 are used to describe the abstract control, now at all without what control, and only one json pairs
As, the json objects also only only one of which attribute id, i.e. { " id ":" textbox0 " }, and the JSON objects are added to $
In document objects, access and operation later to textbox0 can all be searched from document.
SetAttribute methods implication in second code is also with the setAttribute side in HTML DOM programmings
Method, be in HTML DOM to Element object specified attribute assignment, and be in Abstract Programming to the abstract control object specify category
Property assignment, i.e., the value attribute assignments of the attrs objects to tb0 in the corresponding JSON data of this abstract control, now this take out
As control object JSON is described as
Now, many status attributes in JSON descriptions, there occurs for marking the abstract control object attribute
Change.After being finished etc. the JavaScript code of all abstract controls, primary end can be carried out according to this status attribute
The operations such as renewal, deletion, establishment.
3rd code performs the value that getAttribute (" value ") is used to obtain the abstract control, that is, returning should
The value of value attributes under attrs in JSON objects.
Above code is initially the assignment procedure to abstract control, and also a kind of situation is exactly that code is not right at the beginning
Abstract control assignment, but to abstract control value.We are analyzed as follows code:
Var tb0=$ document.getElemtnById (" textbox0 ");// according to id automatically create one it is abstract
Control object
Var val=tb0.getAttribute (" value ");// first in the not no property values of $ document, then lead to
Cross the value of the value attributes of the primary control of service call
If (val==" 123 ")
tb0.setAttribute("value","abc");
In code do not call setAttribute methods first, but first call getAttribute when, that is, go up
State code first, due to the inreal control in now $ document, so going to getAttribute side
, it is necessary to the implicit property value initiated a synchronization call request at JS ends, obtain primary control correspondence attribute, obtains former during method
After raw control property value, then dynamic one abstract control of establishment in $ document, its corresponding points property value is then just to obtain
The property value of the primary control for taking, and this process to be abstract control programming frameworks be automatically performed, developer has without being concerned about
Body realizes, from, just as having there is this abstract control in $ document, and returning to specified attribute value in terms of the aspect of code.
We describe above and how to obtain an abstract control, and how the abstract control is carried out attribute access with
Set.
4th, the data communication between abstract control model and primary control.
Referring to Figure 12, after the programming of abstract control terminates, called by the way that initiation one is primary after one method of JS ends execution,
After being supplied to primary end main thread, primary end main thread to receive this part of JSON data the corresponding JSON data of abstract control,
The description information of each the abstract control in JSON data, performs the code for updating primary UI controls, so as to complete right
The operation of primary control and renewal.
By taking JavaScript and Android as an example, it must be carried out on main thread that Android, which updates UI, so at JS ends
After being programmed by abstract control, it is necessary to after being committed to Android UI main threads in the form of JSON, there is main thread to carry out UI renewals.
In whole process, developer needs only to write the JavaScript code of the programming of abstract control.
It is generalized in generality, for the developer programmed based on abstract control, the number between JS ends and primary end
According to communication, and how primary end parses JSON data that JS ends pass over so as to update these work of primary UI without closing
The heart, as long as being concerned with how to carry out abstract control programming.
Technical scheme, the beneficial effect that can at least reach includes:
(1) from code operational efficiency, the operation of UI controls is updated, is still finally to be realized at primary end, so phase
For the cross-platform modes of HTML5, primary UI efficiency, fluency have absolute predominance.
(2) from programming language, it is converted into by many programmings of the set based on primary language a set of based on JavaScript's
Programming, realizes cross-platform programming.
(3) from the use of code API, there is provided the programming API of approximate HTML DOM, of developer is greatly reduced
Cost is practised, for web developer almost without any obstacle.
In a word, using JavaScript language, using abstract control programming mode, more exploit persons be may enable that
Member, the developer especially with Web development Experiences can realize cross-platform Mobile Development within the most short time.
Technical scheme is described in detail above in association with accompanying drawing, it is contemplated that there is no simplicity, system in correlation technique
One solution for the programming of complicated type control.Existing model programming cannot complete the model of complicated type participation
Programming process.Therefore, the present invention proposes a kind of abstract control model programmer and a kind of abstract control model programmed method,
Can be on the basis of existing model programming mode, the model for making full use of conventional object type to complete abstract object type is compiled
Journey, sets up general, the unified program thread towards abstract control model programming mould that many object types are participated in.
The preferred embodiments of the present invention are the foregoing is only, is not intended to limit the invention, for the skill of this area
For art personnel, the present invention can have various modifications and variations.It is all within the spirit and principles in the present invention, made any repair
Change, equivalent, improvement etc., should be included within the scope of the present invention.
Claims (8)
1. a kind of abstract control model programmer, it is characterised in that including:
Abstract package unit, to the abstract package of primary control, abstract control programming is carried out for using abstract control model;
Data communication unit, after terminating for the programming of abstract control, carries out the data communication between abstract control and primary control,
The abstract package unit, specifically includes:
The genetic module of the abstract controls of DOM and programming mode, for regarding a primary page as a html page, by original
Each primary control is abstracted into an Element object in the raw page;Made by document objects in JavaScript
The access and operation to each control in HTML are realized with the mode of DOM objects;
Abstract control model generation module, for primary control to be defined with HTML, and using in Javascript language
JSON objects describe the corresponding DOM objects of this HTML;
The programming of abstract control model and API module, the programming mode for using for reference HTML DOM, there is provided $ document objects and
API of the same name, completes abstract control programming;After the completion of abstract control programming, based on HTML DOM programmings, using API to abstract control
Part is read out, accesses, operates.
2. abstract control model programmer according to claim 1, it is characterised in that the abstract control model generation
Module describes the JSON of DOM objects, the tag labels of unique mark id, corresponding HTML comprising control, uses HTML element
Base attribute represents the state descriptors of the json objects, an abstract control object of the attribute of primary control in control tree
With the array that container control describes its child control information by children;
And/or,
The $ document objects that the abstract control model programming and API module are provided, are a singletons for Document types
Object, any one abstract control is able to access that by it.
3. the abstract control model programmer according to any one of claim 1-2, it is characterised in that the abstract envelope
Before dress unit carries out the operation of abstract control programming, also include:The UI information of HTML5 and primary control is combined, is refined
To the abstract control model based on JavaScript.
4. the abstract control model programmer according to any one of claim 1-2, it is characterised in that the data are led to
News unit, specifically includes:
Primary calling module, it is primary for after the programming of abstract control terminates, initiating one after JS ends perform a method
Call, the corresponding JSON data of abstract control are supplied to primary end main thread;
The operation of primary control and update module, after receiving this part of JSON data for primary end main thread, according to JSON numbers
The description information of each abstract control in, performs the code for updating primary UI controls, so as to complete to primary control
Operation and renewal.
5. a kind of abstract control model programmed method, it is characterised in that including:
Step 202:Using abstract control model to the abstract package of primary control, abstract control programming is carried out;
Step 204:After abstract control programming terminates, the data communication between abstract control and primary control, the step are carried out
202, specifically include:
Step 302:Regard a primary page as a html page, each primary control in the primary page is abstracted into
One Element object;It is every in realizing to HTML by way of document objects are using DOM objects in JavaScript
One access of control and operation;
Step 304:Primary control is defined with HTML, and this is described using the JSON objects in Javascript language
The corresponding DOM objects of HTML;
Step 306:Use for reference the programming mode of HTML DOM, there is provided $ document objects and API of the same name, complete abstract control and compile
Journey;After the completion of abstract control programming, based on HTML DOM programmings, abstract control is read out using API, accesses, is operated.
6. abstract control model programmed method according to claim 5, it is characterised in that the step 304 describes DOM pairs
The JSON of elephant, the tag labels of unique mark id, corresponding HTML comprising control, carrys out table using the base attribute of HTML element
Show that the state descriptors and container control of json objects, abstract control object of the attribute of primary control in control tree are logical
Children is crossed to describe the array of its child control information;
And/or,
The $ document objects that the step 306 is provided, are a singleton objects for Document types, can be visited by it
Ask any one abstract control.
7. the abstract control model programmed method according to any one of claim 5-6, it is characterised in that the step
Before 202 operations for carrying out abstract control programming, also include:The UI information of HTML5 and primary control is combined, refinement obtains base
In JavaScript abstract control model.
8. the abstract control model programmed method according to any one of claim 5-6, it is characterised in that the step
204, specifically include:
Step 402:After the programming of abstract control terminates, call, will take out by the way that initiation one is primary after one method of JS ends execution
As the corresponding JSON data of control are supplied to primary end main thread;
Step 404:After primary end main thread receives this part of JSON data, each abstract control in JSON data
Description information, performs the code for updating primary UI controls, so as to complete operation and renewal to primary control.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410671291.7A CN104407863B (en) | 2014-11-21 | 2014-11-21 | Abstract control model programmer and method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410671291.7A CN104407863B (en) | 2014-11-21 | 2014-11-21 | Abstract control model programmer and method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104407863A CN104407863A (en) | 2015-03-11 |
CN104407863B true CN104407863B (en) | 2017-07-11 |
Family
ID=52645496
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410671291.7A Active CN104407863B (en) | 2014-11-21 | 2014-11-21 | Abstract control model programmer and method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104407863B (en) |
Families Citing this family (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104714830B (en) * | 2015-04-03 | 2018-03-30 | 普元信息技术股份有限公司 | The system and method for cross-platform exploitation is realized based on primary development language |
CN106681704A (en) * | 2015-11-11 | 2017-05-17 | 北大方正集团有限公司 | Development device and development method of user interface |
CN105760162A (en) * | 2016-02-04 | 2016-07-13 | 四川长虹电器股份有限公司 | Development method for hybrid APP software |
CN106095420A (en) * | 2016-06-03 | 2016-11-09 | 用友网络科技股份有限公司 | Based on mobile cross-platform abstract control model implementation method |
CN106656749A (en) * | 2016-11-30 | 2017-05-10 | 贵州智通天下信息技术有限公司 | Picture-text mixed arrangement message sending method |
CN107423106B (en) * | 2017-07-07 | 2021-04-23 | 北京小米移动软件有限公司 | Method and apparatus for supporting multi-frame syntax |
CN107436927B (en) * | 2017-07-10 | 2019-12-17 | 长城计算机软件与系统有限公司 | Application method and system of UI component |
CN107608675B (en) * | 2017-09-27 | 2020-05-01 | 微景天下(北京)科技有限公司 | Cross-platform front-end development system and method based on virtual document object model |
CN108228220A (en) * | 2018-04-17 | 2018-06-29 | 深圳携程网络技术有限公司 | Using update method and its system, storage medium, electronic equipment |
CN110764768A (en) * | 2018-07-26 | 2020-02-07 | 北京京东金融科技控股有限公司 | Method and device for mutual conversion between model object and JSON object |
CN110532098B (en) * | 2019-08-30 | 2022-03-08 | 广东星舆科技有限公司 | Method and system for providing GPU (graphics processing Unit) service |
CN110889272A (en) * | 2019-11-29 | 2020-03-17 | 中国银行股份有限公司 | Data processing method, device, equipment and storage medium |
CN111176180B (en) * | 2020-01-06 | 2023-04-28 | 深圳市同洲电子股份有限公司 | Heterogeneous internet of things equipment management system |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1302849A2 (en) * | 2001-10-12 | 2003-04-16 | Masateru Minemoto | Multi-dimensional programming device and method |
CN101216766A (en) * | 2008-01-21 | 2008-07-09 | 中兴通讯股份有限公司 | Atom manipulation encapsulation apparatus and method |
CN101403968A (en) * | 2008-11-20 | 2009-04-08 | 用友软件股份有限公司 | Model-driven software development method and system based on template |
CN101539855A (en) * | 2008-12-25 | 2009-09-23 | 厦门亿力吉奥信息科技有限公司 | Service basic software platform |
CN102999339A (en) * | 2012-11-22 | 2013-03-27 | 用友软件股份有限公司 | COM (component object model) component calling device and COM component calling method |
CN103677839A (en) * | 2013-12-17 | 2014-03-26 | 深圳市迈桥科技有限公司 | Generating method and device of UI control across mobile terminal |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101499922B (en) * | 2008-02-02 | 2012-12-12 | 华为技术有限公司 | Data conversion method, apparatus, terminal and server |
-
2014
- 2014-11-21 CN CN201410671291.7A patent/CN104407863B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1302849A2 (en) * | 2001-10-12 | 2003-04-16 | Masateru Minemoto | Multi-dimensional programming device and method |
CN101216766A (en) * | 2008-01-21 | 2008-07-09 | 中兴通讯股份有限公司 | Atom manipulation encapsulation apparatus and method |
CN101403968A (en) * | 2008-11-20 | 2009-04-08 | 用友软件股份有限公司 | Model-driven software development method and system based on template |
CN101539855A (en) * | 2008-12-25 | 2009-09-23 | 厦门亿力吉奥信息科技有限公司 | Service basic software platform |
CN102999339A (en) * | 2012-11-22 | 2013-03-27 | 用友软件股份有限公司 | COM (component object model) component calling device and COM component calling method |
CN103677839A (en) * | 2013-12-17 | 2014-03-26 | 深圳市迈桥科技有限公司 | Generating method and device of UI control across mobile terminal |
Also Published As
Publication number | Publication date |
---|---|
CN104407863A (en) | 2015-03-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104407863B (en) | Abstract control model programmer and method | |
US11842172B2 (en) | Graphical user interface to an artificial intelligence engine utilized to generate one or more trained artificial intelligence models | |
CN111708539B (en) | Application program code conversion method and device, electronic equipment and storage medium | |
Vaupel et al. | Model-driven development of mobile applications for Android and iOS supporting role-based app variability | |
CN102096588B (en) | Control-containing page establishing method | |
CN110825362A (en) | Low-code application software development system and method | |
CN105511873B (en) | User interface control display method and device | |
CN108920133A (en) | Across Programming with Pascal Language method, apparatus, electronic equipment and storage medium | |
CN107861954A (en) | Information output method and device based on artificial intelligence | |
CN110297636A (en) | A kind of automatic production of HTML page and parameter management method based on page configuration file, system and device | |
Haug et al. | A layout technique for class diagrams to be used in product configuration projects | |
CN111275133A (en) | Fusion method and device of classification models and storage medium | |
CN108170435A (en) | A kind of source code conversion method, device and equipment | |
CN114332666A (en) | Image target detection method and system based on lightweight neural network model | |
Thomas | React in action | |
CN109299032B (en) | Data analysing method, electronic equipment and computer storage medium | |
CN107438194A (en) | A kind of intelligent television UI object rendering methods and intelligent television | |
CN115485039B (en) | System and method for supporting creation of game scripts | |
CN116822462A (en) | Method and device for generating simulation report of power system | |
CN110275923A (en) | The management method and equipment of plug-in unit figure | |
CN109885396A (en) | Character string construction method and device in a kind of game application | |
CN116257714A (en) | Method, device, computer equipment and storage medium for generating cascading style sheet | |
CN107665124A (en) | Modularization JavaScript file processing method, equipment and server | |
CN110019177A (en) | The method and apparatus of rule storage | |
CN112799658A (en) | Model training method, model training platform, electronic device, and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Address after: 100094 Beijing city Haidian District North Road No. 68, UFIDA Software Park Applicant after: Yonyou Network Technology Co., Ltd. Address before: 100094 Beijing city Haidian District North Road No. 68, UFIDA Software Park Applicant before: UFIDA Software Co., Ltd. |
|
COR | Change of bibliographic data | ||
GR01 | Patent grant | ||
GR01 | Patent grant |