A method and device for generating a page
By setting template types and configuring template layout methods for page data, the problems of low development efficiency and difficult maintenance in existing technologies are solved, enabling flexible page generation and an efficient development process.
Patent Information
- Application Number
- CN202110008121.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-05
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-01-05
AI Technical Summary
In existing technologies, the table-view protocol method requires the design of complex page logic for different views when developing list view pages with layouts and styles, resulting in low development efficiency and difficulty in maintenance.
By setting template type concepts for group data and item data in the page data, and configuring the corresponding templates and template layout methods, a general approach is used to lay out and load the page data.
It improves development efficiency, is easy to maintain, and can generate pages that meet various needs.
Smart Images

Figure CN113778401B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating a page. Background Art
[0002] Pages on mobile terminals usually include: simple list view pages, list view pages with layouts and styles, and complex pages composed of sections with different layouts and styles. When developing and implementing these pages, the prior art usually uses the relevant table view protocol methods provided by the system to develop lists to achieve visual presentation of the above pages.
[0003] In the process of implementing the present invention, there are at least the following problems in the prior art:
[0004] Table views can only flexibly configure the number of groups and items. Therefore, when using the table view protocol method provided by the system to develop list view pages with layouts and styles, or complex pages composed of sections with different layouts and styles, it is necessary to design complex page logic separately for different views, which results in low development efficiency and is difficult to maintain. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for page generation. By setting the concept of template types for group data and item data in page data and configuring corresponding templates and template layout methods, it is possible to use a common method to layout and load page data to generate pages that meet various needs, thereby improving development efficiency and facilitating maintenance.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for generating a page is provided, comprising:
[0007] Get the business data of the target page;
[0008] Acquire a group data identification method and an item data identification method according to a type data source protocol, and then call the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, and write into the group data template type dictionary and the item data template type dictionary;
[0009] According to the group data template type dictionary and the item data template type dictionary, the corresponding templates and the template layout methods in the template library are retrieved, and the corresponding page group data and page item data are laid out and loaded based on the layout method to generate the visualization section, and then the target page is generated through the visualization section.
[0010] Optionally, calling the group data identification method, identifying the template type of the page group data in the business data, and writing into the group data template type dictionary includes:
[0011] Obtain the number N of groups of the page group data;
[0012] Generate a group type acquisition instruction for the business group data based on the number N;
[0013] Calling the group data identification method, identifying N groups of data in turn, and obtaining template types of the N groups of data to complete the execution of the group type acquisition instruction;
[0014] A group data dictionary of the service data is generated according to the template types of the N group data; wherein the group data dictionary contains a correspondence between group data identifiers and group data template types.
[0015] Optionally, calling the item data identification method, identifying the template type of the page item data in the business data, and writing the item data template type dictionary includes:
[0016] Obtain the number N of groups of the page group data; for the N group data, use the following method to identify the template type of the item data in each group data: for the nth page group data, obtain the number n of items of the item data under the page group data m ; Based on the number n m Generate n for the nth business group data m item data item type acquisition instruction; calling the item data identification method, sequentially m Identify the data items and get n m A template type of item data to complete the execution of the item type acquisition instruction;
[0017] The item data dictionary of the business data is generated according to the template type of each item data under each group data; wherein the item data dictionary contains the correspondence between the group data identifier and the item data dictionary identifier in the group data, and the correspondence between the item data dictionary identifier and the item data template type.
[0018] Optionally, before calling the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, the method further includes:
[0019] Calling the type loading method to retrieve the group data template type dictionary and the item data template type dictionary; clearing the contents in the group data template type dictionary and the item data template type dictionary;
[0020] After clearing, the type loading method is called to generate an instruction for obtaining the number of page group data.
[0021] Optionally, the template library includes:
[0022] The group template type enumeration of group data, the header layout method corresponding to each group template, the item template type enumeration of item data, and the element layout method corresponding to each item template;
[0023] Among them, the header layout method indicates the creation method and configuration information of the group data header; the element layout method indicates the creation method and configuration information of the item data element.
[0024] Optionally, the template library further includes: an enumeration of page template types, and a page layout method corresponding to each page template;
[0025] Generating the target page through the visualization section includes:
[0026] Obtaining the page type of the business data;
[0027] According to the page type, the corresponding page template in the template library and the layout method of the page template are called to layout the visualization section to generate the target page.
[0028] According to another aspect of an embodiment of the present invention, there is provided a page generating device, comprising:
[0029] The acquisition module is used to obtain the business data of the target page;
[0030] A dictionary generation module, used for acquiring a group data identification method and an item data identification method according to a type data source protocol, and then calling the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, and write the group data template type dictionary and the item data template type dictionary;
[0031] The layout module is used to call the corresponding template and the layout method of the template in the template library according to the group data template type dictionary and the item data template type dictionary, and load the layout of the corresponding page group data and page item data based on the layout method to generate the visualization section, and then generate the target page through the visualization section.
[0032] Optionally, the dictionary generation module calls the group data identification method to identify the template type of the page group data in the business data and writes the group data template type dictionary, including:
[0033] Obtain the number N of groups of the page group data;
[0034] Generate a group type acquisition instruction for the business group data based on the number N;
[0035] Calling the group data identification method, identifying N groups of data in turn, and obtaining template types of the N groups of data to complete the execution of the group type acquisition instruction;
[0036] A group data dictionary of the service data is generated according to the template types of the N group data; wherein the group data dictionary contains a correspondence between group data identifiers and group data template types.
[0037] Optionally, the dictionary generation module calls the item data identification method to identify the template type of the page item data in the business data and writes the item data template type dictionary, including:
[0038] Obtain the number N of groups of the page group data; for the N group data, use the following method to identify the template type of the item data in each group data: for the nth page group data, obtain the number n of items of the item data under the page group data m ; Based on the number n m Generate n for the nth business group data m item data item type acquisition instruction; calling the item data identification method, sequentially m Identify the data items and get n m A template type of item data to complete the execution of the item type acquisition instruction;
[0039] The item data dictionary of the business data is generated according to the template type of each item data under each group data; wherein the item data dictionary contains the correspondence between the group data identifier and the item data dictionary identifier in the group data, and the correspondence between the item data dictionary identifier and the item data template type.
[0040] Optionally, before calling the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, the dictionary generation module further includes:
[0041] Calling the type loading method to retrieve the group data template type dictionary and the item data template type dictionary; clearing the contents in the group data template type dictionary and the item data template type dictionary;
[0042] After clearing, the type loading method is called to generate an instruction for obtaining the number of page group data.
[0043] Optionally, the template library includes:
[0044] The group template type enumeration of group data, the header layout method corresponding to each group template, the item template type enumeration of item data, and the element layout method corresponding to each item template;
[0045] Among them, the header layout method indicates the creation method and configuration information of the group data header; the element layout method indicates the creation method and configuration information of the item data element.
[0046] Optionally, the template library further includes: an enumeration of page template types, and a page layout method corresponding to each page template;
[0047] The layout module generates the target page through the visualization section, including:
[0048] Obtaining the page type of the business data;
[0049] According to the page type, the corresponding page template in the template library and the layout method of the page template are called to layout the visualization section to generate the target page.
[0050] According to another aspect of an embodiment of the present invention, there is provided a page generating electronic device, comprising:
[0051] one or more processors;
[0052] a storage device for storing one or more programs,
[0053] When the one or more programs are executed by the one or more processors, the one or more processors implement the page generation method provided by the present invention.
[0054] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the page generation method provided by the present invention is implemented.
[0055] An embodiment of the above invention has the following advantages or beneficial effects: because by setting the concept of template type for group data and item data in page data and configuring corresponding templates and template layout methods, and then using a general method to call the corresponding template layout method to layout and load the page data, so as to generate a technical means of generating pages that meet various needs, it overcomes the technical problem of low development efficiency and difficult maintenance caused by using the table view protocol method provided by the system in the prior art, thereby achieving the technical effect of improving development efficiency and facilitating maintenance.
[0056] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0058] Figure 1 is a schematic diagram of the main process of a page generation method according to the first embodiment of the present invention;
[0059] Figure 2 is a schematic diagram of a protocol method used in a page generation method according to a second embodiment of the present invention;
[0060] Figure 3 is a schematic diagram of a dictionary result generated in a page generation method according to a third embodiment of the present invention;
[0061] Figure 4 is a schematic diagram of registering a template in a template library in a page generation method according to a fourth embodiment of the present invention;
[0062] Figure 5 is a schematic diagram of view design in a page generation method according to a fifth embodiment of the present invention;
[0063] Figure 6 is a schematic diagram of main modules of a page generating device according to a sixth embodiment of the present invention;
[0064] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0065] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0066] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0067] Figure 1 is a schematic diagram of the main process of a page generation method according to the first embodiment of the present invention. Figure 1 As shown, including:
[0068] Step S101, obtaining business data of the target page;
[0069] Step S102: acquiring a group data identification method and an item data identification method according to a type data source protocol, and then calling the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, and write into the group data template type dictionary and the item data template type dictionary;
[0070] Step S103, according to the group data template type dictionary and the item data template type dictionary, call the corresponding template and the template layout method in the template library, layout and load the corresponding page group data and page item data based on the layout method, generate the visualization section, and then generate the target page through the visualization section.
[0071] Based on the table view provided by the system, this method and device adds the concept of type data source (i.e., template type), so that each section (group) in the list and each row (item) of each group have the concept of type. When designing a program, by configuring the type of each section (group) and row (item) in the type data source method, and registering the template of the corresponding type in the relevant method (this template does not need to be compatible with receiving various data, only modular encapsulation is required) for use, it is possible to enable each element of the list to be loaded according to the configured template type, thereby achieving flexible control and diversified effects of list elements.
[0072] The present invention can set the concept of template type for group data and item data in page data and configure corresponding templates and template layout methods, thereby making it possible to use a common method to layout and load page data to generate pages that meet various needs, thereby improving development efficiency and facilitating maintenance.
[0073] Figure 2 is a schematic diagram of a protocol method used in a page generation method according to a second embodiment of the present invention. Figure 2 As shown, two methods are declared in the protocol:
[0074] Method X: tableView:sectionTypeInSection:. This method can be used to obtain the type information of the section with the specified subscript.
[0075] Method Y: tableView:rowTypeAtIndexPath:, which can be used to obtain the type information of the row of the specified IndexPath.
[0076] Among them, indexPath can be understood as a parameter containing two information: section (group) and row (item, which can indicate the row information in the group); for example, when 3 groups are created (from 0 to 2), each group has five tableViewCells, that is, five rows (from 0 to 4), then for a cell, if indexPath.section = 2, indexPath.row = 1, then it can be determined that the cell is the cell in the second row of the third group.
[0077] As long as the view user in the present invention follows the protocol, it can have the declarations of the above two methods for the view in the present invention to call.
[0078] In some embodiments, calling the group data identification method, identifying the template type of the page group data in the business data, and writing into the group data template type dictionary includes:
[0079] Obtain the number N of groups of the page group data;
[0080] Generate a group type acquisition instruction for the business group data based on the number N;
[0081] Calling the group data identification method, identifying N groups of data in turn, and obtaining template types of the N groups of data to complete the execution of the group type acquisition instruction;
[0082] A group data dictionary of the service data is generated according to the template types of the N group data; wherein the group data dictionary contains a correspondence between group data identifiers and group data template types.
[0083] And, in some embodiments, calling the item data identification method, identifying the template type of the page item data in the business data, and writing the item data template type dictionary includes:
[0084] Obtain the number N of groups of the page group data; for the N group data, use the following method to identify the template type of the item data in each group data: for the nth page group data, obtain the number n of items of the item data under the page group data m ; Based on the number n m Generate n for the nth business group data m item data item type acquisition instruction; calling the item data identification method, sequentially m Identify the data items and get n m A template type of item data to complete the execution of the item type acquisition instruction;
[0085] The item data dictionary of the business data is generated according to the template type of each item data under each group data; wherein the item data dictionary contains the correspondence between the group data identifier and the item data dictionary identifier in the group data, and the correspondence between the item data dictionary identifier and the item data template type.
[0086] In each iteration of the section, two things need to be done: the first part is to obtain the type information of the current section; the second part is to obtain the type information of all rows under the current section.
[0087] For the first part, you can Figure 2 Method X in the method protocol obtains the section type information corresponding to the current iteration; if the type information of the section is obtained, the next step is to write the section type information into the sectionTypes dictionary (group data dictionary). Since the section subscript is from 0 to n-1 and will not be repeated, the section subscript and type information are written into the sectionTypes dictionary in the form of key and value. Because the section subscript is a basic type, it is necessary to convert it before writing, that is, convert the basic type subscript into the string object type supported by the dictionary key.
[0088] For the second part of the section iteration, first get the number of rows m corresponding to the section in the current iteration. This m is obtained by calling the numberOfRowsInSection method provided by the system. Similarly, the row subscript is 0 to m-1. After obtaining m, you need to start another row iteration (from 0 to m-1) in the current section iteration. In each iteration of the row, you can use method Y to get the type information of the row corresponding to the current iteration (calling method Y requires passing in an IndexPath object, which is actually an object containing the section subscript and row subscript information. One IndexPath uniquely corresponds to one row); if the type information of the corresponding row is obtained, write the type information of the row into a temporarily created dictionary called rowTypesDic. Also, since the row subscript will not be repeated, the row subscript and type information are written into rowTypesDic in the form of key and value. Because the row subscript is also a basic type, the basic type subscript must also be converted to the string object type supported by the dictionary key.
[0089] If the row iteration started in the current section ends, it means that rowTypesDic has collected all the row type information corresponding to the current section. Therefore, the last step is to write the temporary dictionary rowTypesDic into rowTypes. As mentioned above, after the key conversion, the section subscript and temporary dictionary rowTypesDic are nested in the form of key and value and written into the rowTypes dictionary (item data dictionary).
[0090] Figure 3 is a schematic diagram of a dictionary result generated in a page generation method according to a third embodiment of the present invention; Figure 3 As shown, the figure above shows the contents of the sectionTypes dictionary (group data dictionary), and the figure below shows the contents of the rowTypes dictionary (item data dictionary).
[0091] In some embodiments, before calling the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, the method further includes:
[0092] Calling the type loading method to retrieve the group data template type dictionary and the item data template type dictionary; clearing the contents in the group data template type dictionary and the item data template type dictionary;
[0093] After clearing, the type loading method is called to generate an instruction for obtaining the number of page group data.
[0094] The loadTypes method can be called to clear the two dictionary variables first, in order to clear the type information left over from the last load. Then, an instruction to obtain the number of page group data is generated to obtain the number of sections n, and then the number of sections (groups) is configured in subsequent steps to achieve layout.
[0095] In some embodiments, the template library includes:
[0096] The group template type enumeration of group data, the header layout method corresponding to each group template, the item template type enumeration of item data, and the element layout method corresponding to each item template;
[0097] Among them, the header layout method indicates the creation method and configuration information of the group data header; the element layout method indicates the creation method and configuration information of the item data element.
[0098] You can define the type enumeration of templates that need to be supported according to requirements and encapsulate the corresponding templates; create TypeTableView and specify typeDataSource, and then configure the type data sources of section and row in methods X and Y; finally, register the templates that need to be supported, and create and configure data for each item in each group in the list to complete the registration step.
[0099] Figure 4 FIG. 4 is a schematic diagram of registering a template in a template library in a page generation method according to a fourth embodiment of the present invention. Figure 4 As shown, when creating each cell in the list, an IndexPath object is passed in (indicating which section and row the cell should be placed under when it is created). By calling the getTypeWithIndexPath method of TypeTableView, you can get the row type information corresponding to the IndexPath, and then choose to create cells of different types of templates based on different type information; similarly, when creating and configuring data for a group of headers, when creating the header of each section, you can get the type information of the section by calling the getTypeWithSection method of TypeTableView, and then choose to create different types of headers based on different types.
[0100] In some embodiments, the template library further includes: an enumeration of page template types, and a page layout method corresponding to each page template;
[0101] Generating the target page through the visualization section includes:
[0102] Obtaining the page type of the business data;
[0103] According to the page type, the corresponding page template in the template library and the layout method of the page template are called to layout the visualization section to generate the target page.
[0104] Figure 5 is a schematic diagram of view design in a page generation method according to a fifth embodiment of the present invention. Figure 5As shown, it can be regarded as the design implementation of the device. Since the device is implemented based on a table view, it is called TypeTableView. For the interface part of TypeTableView, three new interfaces are added compared to ordinary table views. The first is a property called typeDataSource, which is the type data source proxy object. By setting the type data source proxy object for TypeTableView (generally, users of TypeTableView will set typeDataSource to themselves), the type information of each section and each row can be accurately obtained. The second interface is the getTypeWithSection: method. Users of TypeTableView can obtain the type information of the section of the specified index by calling this method; the third is the getTypeWithIndexPath: method. Similarly, users of TypeTableView can obtain the type information of the row of the specified IndexPath through this method.
[0105] Next is the internal implementation of TypeTableView, such as Figure 5 As shown. Regarding the reloadData method, this method already exists in ordinary table views and is rewritten in this solution. As can be seen in the figure, when the reloadData method is called, an internal method of loadTypes is called first, and then the parent class's reloadData is called. Among them, the actual acquisition of section and row type information is in the loadTypes method.
[0106] It can be seen that there are two internal variables in TypeTableView that save type information: sectionTypes and rowTypes. sectionTypes is a dictionary type, the key is the subscript of the section, and the value is the type information of the section; rowTypes is a nested dictionary, the key is also the subscript of the section, and the value is a dictionary called rowTypes, which represents all row type information under this section; in rowTypes, the key is the subscript of the row, and the value is the type information of the row.
[0107] In addition to the internal method loadType, TypeTableView also implements getTypeWithSection and getTypeWithIndexPath. getTypeWithSection can convert the passed section index, directly index and return it in the sectionTypes dictionary. getTypeWithIndexPath can first obtain the rowTypesDic of the specified section based on the section in the passed IndexPath object, and then obtain the type information of the specified row based on the row in the IndexPath object and return it.
[0108] Figure 6 is a schematic diagram of main modules of a page generating device 600 according to a sixth embodiment of the present invention. Figure 6 As shown, including:
[0109] Acquisition module 601, used to acquire business data of the target page;
[0110] A dictionary generation module 602 is used to obtain a group data identification method and an item data identification method according to a type data source protocol, and then call the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, and write them into a group data template type dictionary and an item data template type dictionary;
[0111] The layout module 603 is used to call the corresponding template and the layout method of the template in the template library according to the group data template type dictionary and the item data template type dictionary, and load the layout of the corresponding page group data and page item data based on the layout method to generate the visualization section, and then generate the target page through the visualization section.
[0112] Based on the table view provided by the system, this method and device adds the concept of type data source (i.e., template type), so that each section (group) in the list and each row (item) of each group have the concept of type. When designing a program, by configuring the type of each section (group) and row (item) in the type data source method, and registering the template of the corresponding type in the relevant method (this template does not need to be compatible with receiving various data, only modular encapsulation is required) for use, it is possible to enable each element of the list to be loaded according to the configured template type, thereby achieving flexible control and diversified effects of list elements.
[0113] The present invention can set the concept of template type for group data and item data in page data and configure corresponding templates and template layout methods, thereby making it possible to use a common method to layout and load page data to generate pages that meet various needs, thereby improving development efficiency and facilitating maintenance.
[0114] In some embodiments, the dictionary generation module calls the group data identification method, identifies the template type of the page group data in the business data, and writes the group data template type dictionary, including:
[0115] Obtain the number N of groups of the page group data;
[0116] Generate a group type acquisition instruction for the business group data based on the number N;
[0117] Calling the group data identification method, identifying N groups of data in turn, and obtaining template types of the N groups of data to complete the execution of the group type acquisition instruction;
[0118] A group data dictionary of the service data is generated according to the template types of the N group data; wherein the group data dictionary contains a correspondence between group data identifiers and group data template types.
[0119] And, in some embodiments, the dictionary generation module calls the item data identification method, identifies the template type of the page item data in the business data, and writes the item data template type dictionary, including:
[0120] Obtain the number N of groups of the page group data; for the N group data, use the following method to identify the template type of the item data in each group data: for the nth page group data, obtain the number n of items of the item data under the page group data m ; Based on the number n m Generate n for the nth business group data m item data item type acquisition instruction; calling the item data identification method, sequentially m Identify the data items and get n m A template type of item data to complete the execution of the item type acquisition instruction;
[0121] The item data dictionary of the business data is generated according to the template type of each item data under each group data; wherein the item data dictionary contains the correspondence between the group data identifier and the item data dictionary identifier in the group data, and the correspondence between the item data dictionary identifier and the item data template type.
[0122] In each iteration of the section, two things need to be done: the first part is to obtain the type information of the current section; the second part is to obtain the type information of all rows under the current section.
[0123] For the first part, you can Figure 2 Method X in the method protocol obtains the section type information corresponding to the current iteration; if the type information of the section is obtained, the next step is to write the section type information into the sectionTypes dictionary (group data dictionary). Since the section subscript is from 0 to n-1 and will not be repeated, the section subscript and type information are written into the sectionTypes dictionary in the form of key and value. Because the section subscript is a basic type, it is necessary to convert it before writing, that is, convert the basic type subscript into the string object type supported by the dictionary key.
[0124] For the second part of the section iteration, first get the number of rows m corresponding to the section in the current iteration. This m is obtained by calling the numberOfRowsInSection method provided by the system. Similarly, the row subscript is 0 to m-1. After obtaining m, you need to start another row iteration (from 0 to m-1) in the current section iteration. In each iteration of the row, you can use method Y to get the type information of the row corresponding to the current iteration (calling method Y requires passing in an IndexPath object, which is actually an object containing the section subscript and row subscript information. One IndexPath uniquely corresponds to one row); if the type information of the corresponding row is obtained, write the type information of the row into a temporarily created dictionary called rowTypesDic. Also, since the row subscript will not be repeated, the row subscript and type information are written into rowTypesDic in the form of key and value. Because the row subscript is also a basic type, the basic type subscript must also be converted to the string object type supported by the dictionary key.
[0125] If the row iteration started in the current section ends, it means that rowTypesDic has collected all the row type information corresponding to the current section. Therefore, the last step is to write the temporary dictionary rowTypesDic into rowTypes. As mentioned above, after the key conversion, the section subscript and temporary dictionary rowTypesDic are nested in the form of key and value and written into the rowTypes dictionary (item data dictionary).
[0126] In some embodiments, before calling the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, the dictionary generation module further includes:
[0127] Calling the type loading method to retrieve the group data template type dictionary and the item data template type dictionary; clearing the contents in the group data template type dictionary and the item data template type dictionary;
[0128] After clearing, the type loading method is called to generate an instruction for obtaining the number of page group data.
[0129] The loadTypes method can be called to clear the two dictionary variables first, in order to clear the type information left over from the last load. Then, an instruction to obtain the number of page group data is generated to obtain the number of sections n, and then the number of sections (groups) is configured in subsequent steps to achieve layout.
[0130] In some embodiments, the template library includes:
[0131] The group template type enumeration of group data, the header layout method corresponding to each group template, the item template type enumeration of item data, and the element layout method corresponding to each item template;
[0132] Among them, the header layout method indicates the creation method and configuration information of the group data header; the element layout method indicates the creation method and configuration information of the item data element.
[0133] You can define the type enumeration of templates that need to be supported according to requirements and encapsulate the corresponding templates; create TypeTableView and specify typeDataSource, and then configure the type data sources of section and row in methods X and Y; finally, register the templates that need to be supported, and create and configure data for each item in each group in the list to complete the registration step.
[0134] In some embodiments, the template library further includes: an enumeration of page template types, and a page layout method corresponding to each page template;
[0135] The layout module generates the target page through the visualization section, including:
[0136] Obtaining the page type of the business data;
[0137] According to the page type, the corresponding page template in the template library and the layout method of the page template are called to layout the visualization section to generate the target page.
[0138] Figure 7 An exemplary system architecture 700 is shown to which the page generation method or the page generation apparatus according to the embodiment of the present invention can be applied.
[0139] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, 703, network 704 and server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0140] The user can use the terminal devices 701, 702, 703 to interact with the server 705 through the network 704 to receive or send messages, etc. Various applications can be installed on the terminal devices 701, 702, 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0141] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0142] The server 705 may be a server that provides various services, such as a background management server that provides support for the page views to be presented by the user using the terminal devices 701, 702, and 703. The background management server may display the received page data, and feed back the processing results to the terminal device.
[0143] It should be noted that the page generation method provided in the embodiment of the present invention is generally executed by the server 705 , and accordingly, the page generation device is generally disposed in the server 705 .
[0144] It should be understood that Figure 7The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0145] Reference below Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0146] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0147] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0148] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.
[0149] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0150] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0151] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an acquisition module, a dictionary generation module, and a layout module. The names of these modules do not, in some cases, constitute limitations on the modules themselves.
[0152] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: step S101, obtaining the business data of the target page; step S102, obtaining the group data identification method and the item data identification method according to the type data source protocol, and then calling the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, and write the group data template type dictionary and the item data template type dictionary; step S103, according to the group data template type dictionary and the item data template type dictionary, call the corresponding template and the layout method of the template in the template library, and load the layout of the corresponding page group data and page item data based on the layout method to generate the visualization section, and then generate the target page through the visualization section.
[0153] According to the technical solution of the embodiment of the present invention, by setting the concept of template type for group data and item data in page data and configuring corresponding templates and template layout methods, and then using a universal method to call corresponding template layout methods to layout and load page data, so as to generate technical means for generating pages that meet various needs, it overcomes the technical problems of low development efficiency and difficult maintenance caused by using the table view protocol method provided by the system in the prior art, thereby achieving the technical effect of improving development efficiency and facilitating maintenance.
[0154] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A page generation method, characterized in that: include: Get the business data of the target page; Acquire a group data identification method and an item data identification method according to a type data source protocol, and then call the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, and write into the group data template type dictionary and the item data template type dictionary; According to the group data template type dictionary and the item data template type dictionary, the corresponding template and the layout method of the template in the template library are retrieved, and the corresponding page group data and page item data are laid out and loaded based on the layout method to generate a visualization section, and then the target page is generated through the visualization section; The number N of groups of the page group data is obtained; a group type acquisition instruction for the business group data is generated based on the number N; the group data identification method is called to identify the N group data in turn to obtain the template types of the N group data to complete the execution of the group type acquisition instruction; a group data dictionary for the business data is generated according to the template types of the N group data; Obtain the number N of groups of the page group data; for the N group data, use the following method to identify the template type of the item data in each group data: for the nth page group data, obtain the number n of items of the item data under the page group data m ; Based on the number n m Generate n for the nth business group data m item data item type acquisition instruction; calling the item data identification method, sequentially m Identify the data items and get n m The template type of each item data under each group data is used to complete the execution of the item type acquisition instruction; and the item data dictionary of the business data is generated according to the template type of each item data under each group data.
2. The method according to claim 1, characterized in that The group data dictionary contains the correspondence between the group data identifier and the group data template type.
3. The method according to claim 2, characterized in that The item data dictionary contains the correspondence between the group data identifier and the item data dictionary identifier in the group data, and the correspondence between the item data dictionary identifier and the item data template type.
4. The method according to claim 3, characterized in that Before calling the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, the method further includes: Calling the type loading method to retrieve the group data template type dictionary and the item data template type dictionary; clearing the contents in the group data template type dictionary and the item data template type dictionary; After clearing, the type loading method is called to generate an instruction for obtaining the number of page group data.
5. The method according to claim 1, characterized in that The template library includes: The group template type enumeration of group data, the header layout method corresponding to each group template, the item template type enumeration of item data, and the element layout method corresponding to each item template; Among them, the header layout method indicates the creation method and configuration information of the group data header; the element layout method indicates the creation method and configuration information of the item data element.
6. The method according to claim 5, characterized in that The template library also includes: page template type enumeration, and page layout methods corresponding to each page template; Generating the target page through the visualization section includes: Obtaining the page type of the business data; According to the page type, the corresponding page template in the template library and the layout method of the page template are called to layout the visualization section to generate the target page.
7. A page generating device, characterized in that: include: The acquisition module is used to obtain the business data of the target page; A dictionary generation module is used to obtain a group data identification method and an item data identification method according to a type data source protocol, and then call the group data identification method and the item data identification method to respectively identify the template types of the page group data and the page item data in the business data, and write into a group data template type dictionary and an item data template type dictionary; wherein, the number N of groups of the page group data is obtained; a group type acquisition instruction for the business group data is generated based on the number N; the group data identification method is called to identify the N group data in turn to obtain the template types of the N group data to complete the execution of the group type acquisition instruction; and a group data dictionary for the business data is generated according to the template types of the N group data; Obtain the number N of groups of the page group data; for the N group data, use the following method to identify the template type of the item data in each group data: for the nth page group data, obtain the number n of items of the item data under the page group data m ; Based on the number n m Generate n for the nth business group data m item data item type acquisition instruction; calling the item data identification method, sequentially m Identify the data items and get n m The template type of each item data under each group data is used to complete the execution of the item type acquisition instruction; the item data dictionary of the business data is generated according to the template type of each item data under each group data; The layout module is used to call the corresponding template and the layout method of the template in the template library according to the group data template type dictionary and the item data template type dictionary, and load the layout of the corresponding page group data and page item data based on the layout method to generate a visualization section, and then generate the target page through the visualization section.
8. The device according to claim 7, characterized in that The template library includes: The group template type enumeration of group data, the header layout method corresponding to each group template, the item template type enumeration of item data, and the element layout method corresponding to each item template; Among them, the header layout method indicates the creation method and configuration information of the group data header; the element layout method indicates the creation method and configuration information of the item data element.
9. A page generating electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
