Detailed Description
The embodiments of the present invention will be described in further detail with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad invention. It should be further noted that, for convenience of description, only some structures, not all structures, relating to the embodiments of the present invention are shown in the drawings.
Example one
Fig. 1 is a flowchart of a method for checking a page component according to an embodiment of the present invention, where the embodiment is applicable to a case where data check is performed on the page component during program debugging or running, and the method can be executed by a checking device of the page component. The method specifically comprises the following steps:
and S110, matching the page components contained in the host application program with the verification configuration file.
In an embodiment of the present invention, the host application refers to an application configured with a verification configuration file. In order to obtain the user's needs and provide the user with services meeting the user's needs, the host application program usually sets corresponding page components in the page, i.e. visual graphical elements placed on the forms, having functions of executing or triggering code execution by triggering events and completing responses, such as page components like text edit boxes, buttons, and pull-down menus. The user can directly select or click in the selectable items provided in the component without manually adding any data content. However, for a page component such as a text edit box, the user needs to manually input corresponding data content to submit to the background in exchange for the service required by the user. For such page components, when a developer debugs an application program, the attribute of the page component and the data input by the user are required to be limited in format; when the program runs, the user can submit the data and exchange the service only when inputting legal data. Therefore, whether in the program debugging stage or the program running stage, the validity check of the related data related to the page component is very important.
In the embodiment, a verification configuration file which can be configured in the host application program is designed for the host application program, and relevant data of the page component related to the data manually input by the user is verified by using the verification configuration file. The verification configuration file may include types of the page components and verification rules associated with the various page components, where the verification rules may specify format restrictions and specific verification methods of input data in the various page components. In the verification configuration file, a general component verification rule can be set, and a developer can also set a self-defined verification rule according to the actual requirement of a host application program, wherein the priority of the self-defined verification rule is higher than that of the general verification rule. For example, in a certain host application program, a general check rule is set for the cipher text edit box, however, for the transaction cipher text edit box in a certain page, in order to improve the security of the transaction, a developer customizes the check rule of the transaction cipher text edit box, and then when the component is checked, the check rule customized by the developer is preferentially adopted to check the transaction cipher text edit box.
The verification configuration file can be configured in the application program being debugged, and can also be configured in the application program which can be normally used after debugging. In the program debugging stage, the page components contained in the codes of the host application program are matched with the verification configuration file so as to check whether the codes of the host application program contain the error setting of the attributes or the data formats of the page components, and simultaneously, the attributes of the same type of page components or the styles of the data formats in the page components in the host application program can be unified; and in the later program updating or maintaining process, the unified modification of the related programs of the page components is facilitated, and the development efficiency of developers is improved. In the program running stage, the page components contained in the current running page of the host application program are matched with the verification configuration file, so that whether the data input by the user has format errors is checked, and the user is prompted to modify the data.
And S120, determining a target verification component and a target verification mode of the target verification component according to the matching result.
In the embodiment of the invention, the target verification component is a page component needing to be verified. It will be appreciated that the components of the page involved in requiring the user to enter data may all be the target verification components that need to be verified. The target verification mode refers to a specific implementation mode for verifying the target verification component, and it can be understood that the same type of page component is associated with the same verification mode. The page component type is not limited to the type limitation of the page component itself, such as a text edit box, and the page component type may also be limited from the specific type of data input by the user, such as a specific numerical type of time representation or RMB numerical representation.
Since the verification configuration file may include the types of the page components and verification modes associated with various page components, when the page components included in the host application are matched with the verification configuration file, first, for each page component included in the host application, if the verification configuration file also includes the page component at the same time, it indicates that the page component needs to be verified, the page component is used as a target verification component to be verified, and the type of the target verification component is determined. And secondly, matching the target verification component type with the association relationship between the component type and the verification mode stored in the verification configuration file to determine the target verification mode.
Illustratively, in a page of a host application, a text edit box, referred to herein as a date type text edit box, is provided that requires a user to enter date information. Meanwhile, the verification configuration file comprises a date type text edit box and a verification mode related to the date type text edit box. Therefore, when the page component is verified, if the page component is in a program debugging stage, the text editing box in the host application program code is matched with the verification configuration file, the text editing box is determined to be the target verification component and the type of the text editing box is determined to be the date type text editing box, a target verification mode is determined according to the type of the text editing box, namely the date type, and then a developer sets corresponding attributes and a date data format for the text editing box to verify; similarly, if the text editing box in the current running page of the host application program is matched with the verification configuration file in the program running stage, the text editing box is also determined to be the target verification component and the type of the text editing box is determined to be the date type text editing box, a target verification mode is determined according to the type of the text editing box, namely the date type, and then the data input by the user is verified.
S130, when the checking time determined by the host application program is reached, checking the data of the target checking component by adopting the target checking mode.
In the specific embodiment of the present invention, in the process of executing the program code or running the page, the page component in the program code or the page is not checked all the time, but only when the program code needs to execute the program related to the page component or the page runs until the user input data is obtained, the checking timing is reached, at this time, the target checking component needing to be checked and the target checking mode associated with the component type of the target checking component are determined through the checking configuration file, and the related data of the target checking component is checked by using the determined target checking mode. For example, the data input by the user or the data fed back by the server in the page component is checked according to the life cycle of the page.
And S140, feeding back the verification result to the host application program.
In the specific embodiment of the invention, the aim of checking the page component is to feed back the error in the program debugging stage to the developer so as to improve the development efficiency of the developer and facilitate the unification of the page component style in the host application program; or the error of the data input by the user in the page component is fed back to the user, so that the user can modify the input of the data. In the program debugging stage, the verification result can be prompted to a developer in an interface callback mode, and the developer obtains the verification result by checking a specific variable; or, corresponding prompt information is output through the console, so that a developer can more intuitively check the verification result. In the program running stage, the check result may be prompted to the User through a User Interface (UI), for example, a prompt window pops up.
S150, updating the verification components stored in the verification configuration file and the verification mode of the verification components.
In the embodiment of the present invention, the verification configuration file may be updated with the upgrade or update of the host application, where the verification component stored in the verification configuration file, that is, the target verification component that needs to be verified in the host application, and the verification manner associated with the verification component may be updated. Since the verification configuration file in the embodiment is configurable, only the verification configuration file needs to be updated, and the verification mode of each page component in the host application program does not need to be modified independently, so that the development efficiency of a developer is improved.
According to the technical scheme, the configurable page component verification configuration file is provided, the page component contained in the host application program configured with the verification configuration file is matched with the verification configuration file, the target verification component needing to be verified and the target verification mode associated with the target verification component are obtained, the target verification component is verified in the target verification mode, and the verification result is fed back to the host application program, so that a user or a developer can know the verification result of the page component. The embodiment of the invention can provide configurable uniform verification rules for developers, and realizes that the front-end user verifies the data input in the page component and the back-end developer verifies the setting of the page component; and when updating or modifying in the later period, the verification configuration file can be modified uniformly, the verification rules of all the components do not need to be modified one by one, and the development, updating and maintenance efficiency of the application program and the verification rules by a developer is improved.
Example two
On the basis of the first embodiment, the present embodiment provides a preferred implementation of a verification method for a page component, which can verify the page component according to a lifecycle of page operation. Fig. 2 is a flowchart of a verification method for a page component according to a second embodiment of the present invention, and as shown in fig. 2, the method includes the following specific steps:
s210, matching the page components contained in the host application program with the verification configuration file.
Preferably, in the program debugging stage, the page components contained in the code of the host application program are matched with the verification configuration file; or, in the program running stage, matching the page components contained in the current running page of the host application program with the verification configuration file.
In the embodiment of the present invention, the verification configuration file may be configured in the application program being debugged, or may be configured in the application program that can be normally used after debugging. In the program debugging stage, the page components contained in the codes of the host application program are matched with the verification configuration file so as to check whether the codes of the host application program contain the error setting of the attributes or the data formats of the page components, and simultaneously, the attributes of the same type of page components or the styles of the data formats in the page components in the host application program can be unified; and in the later program updating or maintaining process, the unified modification of the related programs of the page components is facilitated, and the development efficiency of developers is improved. In the program running stage, the page components contained in the current running page of the host application program are matched with the verification configuration file, so that whether the data input by the user has format errors is checked, and the user is prompted to modify the data.
S220, aiming at each page component contained in the host application program, if the page component is contained in the verification configuration file, the page component is used as the target verification component, and the type of the target verification component is determined.
In the embodiment of the present invention, the verification configuration file may include the type of the page component to be verified, so that each page component included in the host application program is matched with the page component in the verification configuration file one by one, so as to clarify the target verification component to be verified in the host application program. And determining the type of the target verification component according to the attribute information of the target verification component or the limitation of the input data.
S230, matching the target verification component type with the association relationship between the component type and the verification mode stored in the verification configuration file, and determining the target verification mode.
In the specific embodiment of the present invention, the verification configuration file may include verification modes associated with various page components, where the verification modes specify a class of page components or a verification rule of a certain page component. Therefore, after the target verification component and the type thereof in the host application program are determined, the target verification mode of the target verification component is obtained through matching according to the incidence relation between the page component type and the verification mode stored in the verification configuration file.
And S240, monitoring the life cycle of the current running page of the host application program.
In the specific embodiment of the present invention, in the execution of the program code or the running process of the page, the page component in the program code is not checked all the time, but only when the program code needs to execute the program related to the page component or when the page runs until the user input data is acquired, the checking time is reached. Thus, there is a need to snoop the lifecycle of the currently running page of the host application to trigger component checking operations at the appropriate time.
The life cycle of a page refers to the whole process from birth to death of the page. When a new page is entered through the operation of the website or the existing page, the server receives the page request of the new page, and the life cycle of the new page starts to monitor the new page. The server creates an independent and brand-new page according to the page request, performs appropriate processing, returns the finally generated page to the browser, then releases the newly generated page, and ends the life cycle of the new page.
And S250, according to the life cycle of the current running page, when the verification opportunity determined by the host application program is reached, verifying the data input by the user in the target verification component by adopting the target verification mode.
In the specific embodiment of the invention, the page which only contains the website information of the new page in the page request does not generally relate to the scene input by the user, so the lightweight page access does not need the verification process of the page component. However, for a page containing additional information in the page request, a jump to a new page is usually made on the basis of the previous page, and therefore, the generation of such a page may need to be combined with processing the additional information to feed back to the browser a new page. In such a page, whether a scene input by a user is involved in the life cycle of the page needs to be monitored, and if the scene input by the user is involved, a page component involved in the user input is verified according to a verification configuration file.
Preferably, the data input by the user in the target verification component is verified in the target verification mode; or, the data acquired by the target verification component from the server is verified in the target verification mode.
In the embodiment of the invention, not only the data input by the front-end user can be verified, but also the data returned by the background server can be verified. Illustratively, for a date type text edit box, the host application and verification configuration file have a data format setting of 2018-1-1. When the user inputs the date 2018/1/15 in the page component or the date acquired by the page component from the server is 2018/1/15, the verification configuration file verifies the data input by the user or the data acquired by the page component from the server according to the monitored specific time of the life cycle of the page, and the verification result of the data format error can be obtained because the two date formats are not matched. In addition, codes related to page components in program debugging can be checked in the same way, and whether the settings of the developer are correct or not can be verified.
And S260, feeding back the verification result to the host application program.
In the specific embodiment of the present invention, in the program debugging phase, preferably, the check result is fed back to the host application program through the interface callback prompt; or, the check result is fed back to the host application program through the information prompt output by the console. In the program running stage, preferably, the checking result is fed back to the host application program through a UI (user interface) prompt.
According to the technical scheme, the configurable page component verification configuration file is provided, firstly, the page components contained in the host application program are matched with the page components stored in the verification configuration file one by one, and the target verification component needing to be verified is obtained; secondly, determining a target verification mode according to the type of the target verification component; then, according to the monitored page period, when the verification time is reached, a target verification mode is utilized to verify the target verification component; and finally, feeding back the verification result to the host application program so that the user or the developer can know the verification result of the page component. The embodiment of the invention can provide configurable uniform verification rules for developers, and realizes the verification of the data input by a front-end user in the page component and the setting of the page component by a back-end developer according to the monitored life cycle of the page. By configuring the uniform verification configuration file for the application program, the development efficiency of the application program by a developer is improved.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a checking apparatus for a page component according to a third embodiment of the present invention, where this embodiment is applicable to a case where data checking is performed on a page component during program debugging or running, and the apparatus can implement the checking method for a page component according to any embodiment of the present invention. The device specifically includes:
aconfiguration matching module 310, configured to match a page component included in the host application with the verification configuration file;
averification determining module 320, configured to determine a target verification component and a target verification manner of the target verification component according to a matching result;
theverification module 330 is configured to verify, in the case of reaching a verification opportunity determined by the host application, the relevant data of the target verification component in the target verification manner;
and aresult feedback module 340, configured to feed back the verification result to the host application.
Theconfiguration matching module 310 is specifically configured to:
in the program debugging stage, matching a page component contained in a code of a host application program with a verification configuration file; or, in the program running stage, matching the page components contained in the current running page of the host application program with the verification configuration file.
Further, theverification determining module 320 includes:
a target verification component determining unit, configured to, for each page component included in the host application, if the page component is included in the verification configuration file, use the page component as the target verification component, and determine the type of the target verification component;
and the target verification mode determining unit is used for matching the target verification component type with the association relationship between the component type and the verification mode stored in the verification configuration file to determine the target verification mode.
Further, theverification module 330 includes:
the monitoring unit is used for monitoring the life cycle of the current running page of the host application program;
and the verification unit is used for verifying the data input by the user in the target verification component by adopting the target verification mode when the verification time determined by the host application program is reached according to the life cycle of the current running page.
Preferably, theverification module 330 is specifically configured to:
verifying the data input by the user in the target verification component by adopting the target verification mode; or, the data acquired by the target verification component from the server is verified in the target verification mode.
Further, theresult feedback module 340 is specifically configured to:
feeding back the checking result to the host application program through an interface callback prompt; or
And outputting information prompt through the console to feed back the verification result to the host application program.
Further, theresult feedback module 340 is specifically configured to:
and feeding back the verification result to the host application program through a UI (user interface) prompt.
Further, the apparatus further comprises:
anupdating module 350, configured to update the verification component stored in the verification configuration file and the verification manner of the verification component.
According to the technical scheme of the embodiment, through the mutual cooperation of the functional modules, the functions of determining the target verification component to be verified, determining the target verification mode, monitoring the life cycle of the page, verifying the component, feeding back the verification result, updating the verification configuration file and the like are realized. The embodiment of the invention can provide configurable uniform verification rules for developers, and realizes that the front-end user verifies the data input in the page component and the back-end developer verifies the setting of the page component; and when updating or modifying in the later period, the verification configuration file can be modified uniformly, the verification rules of all the components do not need to be modified one by one, and the development, updating and maintenance efficiency of the application program and the verification rules by a developer is improved.
Example four
Fig. 4 is a schematic structural diagram of a server according to a fourth embodiment of the present invention, and fig. 4 shows a block diagram of an exemplary server suitable for implementing the embodiments of the present invention. The server shown in fig. 4 is only an example, and should not bring any limitation to the function and the scope of use of the embodiments of the present invention.
Theserver 12 shown in fig. 4 is only an example, and should not bring any limitation to the function and the scope of use of the embodiment of the present invention.
As shown in FIG. 4, theserver 12 is in the form of a general purpose computing device. The components of theserver 12 may include, but are not limited to: one or more processors orprocessing units 16, asystem memory 28, and abus 18 that couples various system components including thesystem memory 28 and theprocessing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Theserver 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible byserver 12 and includes both volatile and nonvolatile media, removable and non-removable media.
Thesystem memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/orcache memory 32. Theserver 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only,storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, and commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected tobus 18 by one or more data media interfaces.Memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) ofprogram modules 42 may be stored, for example, inmemory 28,such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment.Program modules 42 generally carry out the functions and/or methodologies of embodiments described herein.
Theserver 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device,display 24, etc.), with one or more devices that enable a user to interact with theserver 12, and/or with any devices (e.g., network card, modem, etc.) that enable theserver 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O)interface 22. Also, theserver 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via thenetwork adapter 20. As shown, thenetwork adapter 20 communicates with the other modules of theserver 12 via thebus 18. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with theserver 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Theprocessing unit 16 executes various functional applications and data processing, such as implementing a verification method for page components provided by embodiments of the present invention, by running a program stored in thesystem memory 28.
EXAMPLE five
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program (or referred to as a computer-executable instruction) is stored, where the computer program is used to execute a method for checking a page component when executed by a processor, and the method includes:
matching a page component contained in the host application program with the verification configuration file;
determining a target checking component and a target checking mode of the target checking component according to a matching result;
when the verification opportunity determined by the host application program is reached, verifying the data of the target verification component by adopting the target verification mode;
and feeding back the checking result to the host application program.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It should be noted that the foregoing is only a preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will appreciate that the embodiments of the present invention are not limited to the specific embodiments described herein, and that various obvious changes, adaptations, and substitutions are possible, without departing from the scope of the embodiments of the present invention. Therefore, although the embodiments of the present invention have been described in more detail through the above embodiments, the embodiments of the present invention are not limited to the above embodiments, and many other equivalent embodiments may be included without departing from the concept of the embodiments of the present invention, and the scope of the embodiments of the present invention is determined by the scope of the appended claims.