A linkage form generation method and device based on an interface description language
By using an interface description language-based linked form generation method, the problems of high developer requirements and platform limitations in existing technologies are solved. This method enables cross-platform form generation and data parsing, reduces repetitive workload for developers, and provides linked forms with formatting and validation functions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SUPCON TECH CO LTD
- Filing Date
- 2022-12-01
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies place high demands on developers when creating complex forms, have platform limitations, and cannot effectively solve the problem of repetitive work between writing and parsing form data.
A linked form generation method based on an interface description language is adopted. By extending the processing of form options, the editing code of the interface description language is obtained, and a cross-platform renderer is used for rendering. Combined with internationalization resources and component option processing, the target form is generated.
It reduces repetitive workload for developers, provides linked forms with formatting and validation functions, supports cross-platform applications, and utilizes the serialization and deserialization functions of the interface description language.
Smart Images

Figure CN115857927B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of interface development technology, and specifically relates to a method and apparatus for generating linked forms based on an interface description language. Background Technology
[0002] Forms are commonly used data input components in user interfaces. In systems with a large number of user input requirements, the number and complexity of forms will increase dramatically, which directly leads to a sharp increase in the workload of developers in writing form interfaces and parsing form data.
[0003] In existing form generation technologies, forms are generally defined using JSON Schema or XML Schema, but this method requires writing complex schema files, which poses a significant challenge to developers or maintainers when creating complex forms. Secondly, a method that simulates HTML DOM nodes can be used to drive form styles and data through events. However, this method requires a high level of skill from developers, has certain platform limitations, and cannot solve the problem of repetitive work between writing the form interface and parsing the form data. Summary of the Invention
[0004] This application addresses the aforementioned challenges in creating complex forms for developers and maintainers, the high demands placed on developers by event-driven approaches, the platform limitations, and the inability to resolve repetitive tasks between creating the form interface and parsing form data. It proposes a method and apparatus for generating linked forms based on an interface description language, the technical solution of which is as follows:
[0005] In a first aspect, embodiments of this application provide a method for generating linked forms based on an interface description language, including:
[0006] Expand at least two form options according to the preset form requirements;
[0007] Based on at least two form options after expansion processing, obtain the first edit code; wherein the first edit code is written in an interface description language;
[0008] When at least two form options after expansion contain internationalized resource prefixes, add a second edit code corresponding to the internationalized resource prefix to the first edit code to obtain the third edit code;
[0009] The third-party edit code is rendered into the target form based on the renderer.
[0010] In one alternative of the first aspect, when at least two form options after expansion contain internationalized resource prefixes, after adding a second edit code corresponding to the internationalized resource prefix to the first edit code to obtain a third edit code, before rendering the third edit code as the target form based on the renderer, the method further includes:
[0011] Filter the message renderer options from at least two form options after expansion processing, and determine the form container to render based on the message renderer options;
[0012] The renderer renders the third-party edit code into the target form, including:
[0013] Based on the renderer and the form container, the third-party edit code is rendered into the target form.
[0014] In another alternative to the first aspect, the third-party editing code is rendered as the target form based on the renderer and the rendering form container, including:
[0015] Load internationalization resources based on the second-edit code;
[0016] In the third editing code, the first descriptor code is obtained, and the fields of the first descriptor code are processed by depth-first traversal to obtain the field descriptor corresponding to each field in the first descriptor code;
[0017] When it is detected that the hidden field option of any field descriptor is enabled, the field corresponding to the field descriptor is first hidden;
[0018] Based on the renderer and the form container, internationalization resources and third-edit code that has undergone the first hiding process are rendered into the target form.
[0019] In another alternative to the first aspect, based on the renderer and the form container, internationalization resources and third-edit code after the first hiding process are rendered into the target form, including:
[0020] Based on the renderer, the layout processing is performed on the components corresponding to the internationalized resources and the third-edit code after the first hiding process.
[0021] When it is detected that the internationalized resources and the fields of the third edit code after the first hiding process are not in the display area, the internationalized resources and the fields of the third edit code after the first hiding process are hidden in the display area.
[0022] Based on the renderer and the form container, the internationalized resources after the second hiding process and the third editing code are rendered into the target form.
[0023] In another alternative to the first aspect, based on the renderer and the rendering form container, the internationalized resources after the second hiding process and the third editing code are rendered as the target form, including:
[0024] The second descriptor code is obtained from the internationalized resources after the second hiding process and the third editing code, and the component options corresponding to the fields are determined in the second descriptor code;
[0025] The target form is obtained by rendering the field input component based on the renderer, the form container, and the component options corresponding to the field.
[0026] In another alternative to the first aspect, after rendering the field input component based on the renderer, the form container, and the component options corresponding to the field, and before obtaining the target form, the following is also included:
[0027] The style options corresponding to the fields are determined in the second descriptor code;
[0028] Based on the renderer, the form container, and the style options corresponding to the fields, the style of the field input component after rendering is applied to obtain the target form.
[0029] In another alternative to the first aspect, before rendering the field input component based on the renderer, the form container, and the component options corresponding to the field to obtain the target form, the following is also included:
[0030] The autocomplete option corresponding to the field is determined in the second descriptor code;
[0031] Load the candidate field component corresponding to the autocomplete options;
[0032] After rendering the field input component based on the renderer, the form container, and the component options corresponding to the field to obtain the target form, it also includes:
[0033] When user input is detected, the candidate field component is rendered based on the renderer.
[0034] Secondly, embodiments of this application provide a linked form generation device based on an interface description language, comprising:
[0035] The extended processing module is used to extend the processing of at least two form options according to preset form requirements;
[0036] The first determining module is used to obtain the first editing code based on at least two form options after expansion processing; wherein the first editing code is written in an interface description language.
[0037] The second determining module is used to add a second editing code corresponding to the internationalized resource prefix to the first editing code when at least two form options after expansion processing contain internationalized resource prefixes, thus obtaining a third editing code.
[0038] The form generation module is used to render third-party edit code into a target form based on the renderer.
[0039] In one alternative embodiment of the second aspect, the device further includes:
[0040] When at least two form options after expansion contain internationalized resource prefixes, add a second edit code corresponding to the internationalized resource prefix to the first edit code to obtain a third edit code. Before rendering the third edit code into the target form based on the renderer, filter out the message renderer option from the at least two form options after expansion and determine the rendering form container based on the message renderer option.
[0041] The renderer renders the third-party edit code into the target form, including:
[0042] Based on the renderer and the form container, the third-party edit code is rendered into the target form.
[0043] In another alternative solution to the second aspect, the form generation module specifically includes:
[0044] Load internationalization resources based on the second-edit code;
[0045] In the third editing code, the first descriptor code is obtained, and the fields of the first descriptor code are processed by depth-first traversal to obtain the field descriptor corresponding to each field in the first descriptor code;
[0046] When it is detected that the hidden field option of any field descriptor is enabled, the field corresponding to the field descriptor is first hidden;
[0047] Based on the renderer and the form container, internationalization resources and third-edit code that has undergone the first hiding process are rendered into the target form.
[0048] In another alternative solution to the second aspect, the form generation module also includes:
[0049] Based on the renderer, the layout processing is performed on the components corresponding to the internationalized resources and the third-edit code after the first hiding process.
[0050] When it is detected that the internationalized resources and the fields of the third edit code after the first hiding process are not in the display area, the internationalized resources and the fields of the third edit code after the first hiding process are hidden in the display area.
[0051] Based on the renderer and the form container, the internationalized resources after the second hiding process and the third editing code are rendered into the target form.
[0052] In another alternative solution to the second aspect, the form generation module also includes:
[0053] The second descriptor code is obtained from the internationalized resources after the second hiding process and the third editing code, and the component options corresponding to the fields are determined in the second descriptor code;
[0054] The target form is obtained by rendering the field input component based on the renderer, the form container, and the component options corresponding to the field.
[0055] In another alternative solution to the second aspect, the form generation module also includes:
[0056] After rendering the field input component based on the renderer, the form container, and the component options corresponding to the field, the style options corresponding to the field are determined in the second descriptor code before the target form is obtained.
[0057] Based on the renderer, the form container, and the style options corresponding to the fields, the style of the field input component after rendering is applied to obtain the target form.
[0058] In another alternative embodiment of the second aspect, the device further includes:
[0059] Before rendering the field input component based on the renderer, the form container, and the component options corresponding to the field to obtain the target form, the autocomplete options corresponding to the field are determined in the second descriptor code.
[0060] Load the candidate field component corresponding to the autocomplete options;
[0061] After rendering the field input component based on the renderer, the form container, and the component options corresponding to the field to obtain the target form, it also includes:
[0062] When user input is detected, the candidate field component is rendered based on the renderer.
[0063] Thirdly, embodiments of this application also provide a linkage form generation device based on an interface description language, including a processor and a memory;
[0064] The processor is connected to the memory;
[0065] Memory, used to store executable program code;
[0066] The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the linkage form generation method based on interface description language provided in the first aspect or any implementation of the first aspect of the embodiments of this application.
[0067] Fourthly, embodiments of this application provide a computer storage medium storing a computer program, which includes program instructions. When executed by a processor, the program instructions can implement the linked form generation method based on an interface description language provided in the first aspect or any implementation of the first aspect of this application.
[0068] In this embodiment, when generating the form, at least two form options can be extended according to preset form requirements. Based on the extended form options, a first editing code is obtained. The first editing code is written in an interface description language. When the extended form options contain internationalized resource prefixes, a second editing code corresponding to the internationalized resource prefix is added to the first editing code to obtain a third editing code. The third editing code is then rendered into the target form using a renderer. By using an interface description language as the form's writing language and rendering it with a cross-platform renderer, not only can a linked form with formatting and validation functions be obtained, but the serialization and deserialization functions of the interface description language can also be utilized to reduce repetitive workload for developers. Attached Figure Description
[0069] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0070] Figure 1 A schematic diagram of the overall process of a linked form generation method based on an interface description language provided in this application embodiment;
[0071] Figure 2 A schematic diagram illustrating the effect of a linked form based on an interface description language, provided as an embodiment of this application;
[0072] Figure 3 A schematic diagram illustrating another linked form effect based on an interface description language, provided for an embodiment of this application;
[0073] Figure 4 A schematic diagram of the structure of a linkage form generation device based on an interface description language provided in an embodiment of this application;
[0074] Figure 5 This is a schematic diagram of another linkage form generation device based on an interface description language provided in an embodiment of this application. Detailed Implementation
[0075] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0076] In the following description, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. The following description provides multiple embodiments of this application, which can be substituted or combined with each other. Therefore, this application can also be considered to include all possible combinations of the same and / or different embodiments described. Thus, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then this application should also be considered to include embodiments containing one or more other possible combinations of A, B, C, and D, even if such embodiments are not explicitly described in the following text.
[0077] The following description provides examples and does not limit the scope, applicability, or examples set forth in the claims. Changes may be made to the function and arrangement of the described elements without departing from the scope of this application. Various processes or components may be appropriately omitted, substituted, or added to the examples. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Furthermore, features described with respect to some examples may be combined into other examples.
[0078] Please see Figure 1 , Figure 1 This illustration shows an overall flowchart of a linked form generation method based on an interface description language, as provided in an embodiment of this application.
[0079] like Figure 1 As shown, this method for generating linked forms based on an interface description language can include at least the following steps:
[0080] Step 102: Expand at least two form options according to the preset form requirements.
[0081] In this embodiment, the interactive form generation method based on an interface description language can be applied to, but is not limited to, a server. The server can obtain code edited by developers using the interface description language during the form generation process, and render this code using a cross-platform renderer to generate the form. Furthermore, during the user's form filling process, hidden field components can be rendered based on the user's input actions. This not only achieves form dynamism but also leverages the serialization and deserialization capabilities of the interface description language, greatly reducing repetitive workload for developers. It is understood that the interface description language here can be, but is not limited to, Protobuf, a high-efficiency protocol data exchange format tool library provided by Google, which offers support for C++, Java, and Python languages.
[0082] The server mentioned in the embodiments of this application may be a tablet computer, desktop computer, laptop computer, ultra-mobile personal computer (UMPC), handheld computer, netbook, personal digital assistant (PDA), routing device, and virtual reality device, etc.
[0083] Specifically, when generating a form, at least two form options can be expanded based on preset form requirements. These at least two form options can include, but are not limited to, any two of the following: message options, field options, enumeration options, and select-one options. The preset form requirements can be understood as the requirements of the selected renderer and predefined form functions. These predefined form functions can include, but are not limited to, filling in user identity information, etc.
[0084] This example uses the extended handling of message options. You can, but are not limited to, editing the code as shown in the example below:
[0085] extend google.protobuf.MessageOptions {
[0086] optional MessageRenderer default_renderer = 4000;
[0087] optional string i18n_prefix = 4001;
[0088] }
[0089] The second row can be understood as the default message renderer, which is the container for selecting the message to be rendered, such as but not limited to page format or tiled content format; the third row can be understood as the internationalization resource prefix, which is the concatenation of internationalization resource fields.
[0090] Here, we can also take the extended processing of field options as an example. You can, but are not limited to, editing the code according to the example shown below:
[0091] extend google.protobuf.FieldOptions {
[0092] optional FieldComponent component = 4100;
[0093] optional google.protobuf.Struct component_options = 4101;
[0094] optional string required_condition = 4102;
[0095] optional bool hide = 4103;
[0096] optional string hide_condition = 4104;
[0097] repeated FieldValidator validators = 4105;
[0098] repeated string custom_validators = 4106;
[0099] repeated string auto_completers = 4107;
[0100] optional FieldStyle field_style = 4108;
[0101] optional FieldFormatter formatter = 4109;
[0102] optional string custom_formatter = 4110;
[0103] optional double min_size = 4150;
[0104] optional double max_size = 4151;
[0105] optional double default_size = 4152;
[0106] optional string size_condition = 4153;
[0107] }
[0108] Specifically, the code examples mentioned above may involve components for rendering field input boxes and their options, field display control, field enablement judgment, field content inspector, field autocomplete suggestions, and field styles.
[0109] Here, you can also choose an extended processing method for one option as an example. You can edit the code according to the example shown below, but you are not limited to it:
[0110] extend google.protobuf.OneofOptions {
[0111] optional OneOfComponent selector = 4200;
[0112] optional uint64 default_option = 4201;
[0113] optional bool auto_fallback = 4202;
[0114] }
[0115] The example code above can be interpreted as hiding the selector when the number of selectable fields is 0, and rendering the selector as a regular field tag when the number of selectable fields is 1.
[0116] Step 104: Obtain the first edit code based on at least two form options after expansion processing.
[0117] Specifically, after expanding on at least two form options, the first editing code edited by the developer can be obtained. Taking a student information filling form as an example, the editing code can be, but is not limited to, the example editing code shown below:
[0118] message StudentInformation {
[0119] option (default_renderer) = MESSAGE_RENDERER_PAGE;
[0120] string first_name = 1 [ (required) = true ];
[0121] string last_name = 2 [ (required) = true ];
[0122] Gender gender = 8 [ (required) = true ];
[0123] google.protobuf.Timestamp birthday = 3 [
[0124] (required) = true,
[0125] (component) = FIELD_COMPONENT_DATE_TIME,
[0126] (component_options) = {
[0127] fields : [
[0128] {
[0129] key : "default",
[0130] value : {string_value : "now"}
[0131] },
[0132] {
[0133] key : "hideTime",
[0134] value : {bool_value : true}
[0135] } ]
[0137] } ];
[0139] oneof identification {
[0140] option (selector) = ONE_OF_COMPONENT_DROPDOWN;
[0141] option (default_option) = 4;
[0142] string id_number = 4
[0143] [(required)=true,(validators)= FIELD_VALIDATOR_ID_NUMBER ];
[0144] string passport_number = 5
[0145] [(required)=true,(validators)=FIELD_VALIDATOR_NUMBERS_LETTERS];
[0146] }
[0147] string citizenship = 7 [
[0148] (required_condition) = ".identification == 5",
[0149] (hide_condition) = ".identification != 5",
[0150] (auto_completers) = "country / region" ];
[0152] repeated Parent parents = 6 [ (max_size) = 2 ];
[0153] message Parent {
[0154] option (default_renderer) = MESSAGE_RENDERER_FLAT;
[0155] }
[0156] enum Gender {
[0157] GENDER_UNSPECIFIED = 0;
[0158] }
[0159] }
[0160] The example editing code above corresponds to the following information that must be filled in on a separate page: first name, last name, gender, date of birth, identity information, and passport number. Optional information includes parents' information. The date of birth is accurate to the day, meaning the hour, minute, and second are hidden. The selector component for the identity information is a drop-down menu, meaning the identity information is the ID card number. The passport number has a specific format, and the corresponding country / region data can be used for auto-completion.
[0161] See here. Figure 2 The illustration shown is a schematic diagram of a linked form effect based on an interface description language, provided by an embodiment of this application. For example... Figure 2 As shown, the required information in this form includes first name, last name, gender, date of birth, identity information, and ID number. The gender information is displayed as a drop-down menu; the date of birth is specified to the day and is displayed as a calendar menu; the identity information is displayed as a drop-down menu and the ID number has a specific format.
[0162] It is understandable that when the ID number entered is in the wrong format, the form can mark the incorrect ID number, for example, but not limited to, highlighting it in red.
[0163] Step 106: When at least two form options after expansion contain internationalized resource prefixes, add a second edit code corresponding to the internationalized resource prefix to the first edit code to obtain the third edit code.
[0164] Specifically, after extending the message options, when the extended content is detected to contain an internationalized resource prefix, a second edit code corresponding to the internationalized resource prefix can be added to the first edit code to obtain the final third edit code to be rendered.
[0165] The second code edit here uses the Chinese ICU ResourceBundle format as an example. You can, but are not limited to, referring to the example code shown below:
[0166] zh {
[0167] StudentInformation {
[0168] first_name
[0169] last_name
[0170] gender
[0171] birthday
[0172] identification
[0173] id_number
[0174] passport_number
[0175] citizenship
[0176] citizenship#placeholder
[0177] citizenship#hint
[0178] Parent {
[0179] }
[0180] Gender {
[0181] }
[0182] }
[0183] }
[0184] Among them, fields with the suffix #placeholder correspond to placeholder text during rendering, and fields with the suffix #hint correspond to helpful hint text.
[0185] As an optional embodiment of this application, when at least two form options after expansion processing contain internationalized resource prefixes, after adding a second edit code corresponding to the internationalized resource prefix to the first edit code to obtain a third edit code, before rendering the third edit code into the target form based on the renderer, the method further includes:
[0186] Filter the message renderer options from at least two form options after expansion processing, and determine the form container to render based on the message renderer options;
[0187] The renderer renders the third-party edit code into the target form, including:
[0188] Based on the renderer and the form container, the third-party edit code is rendered into the target form.
[0189] Specifically, before rendering the third-party edit code based on the renderer, a suitable rendering form container needs to be selected in advance according to the message renderer options. This suitable rendering form container can then be used to render the third-party edit code based on the renderer. For example, but not limited to, when the message renderer option is MESSAGE_RENDERER_FLAT, the rendering form container can be selected as a tiled list container; when the message renderer option is MESSAGE_RENDERER_PAGE, the rendering form container can be selected as a paginated display container.
[0190] See also: Figure 3 The illustration shown is a schematic diagram of another linked form effect based on an interface description language provided in an embodiment of this application. For example... Figure 3 As shown, the required information in this form includes, in order: first name, last name, gender, date of birth, identity information, passport number, and nationality. The gender selection option is a drop-down menu; the date of birth is specified to the day and has a calendar menu selection option; the identity information selection option is a drop-down menu, and the passport number has a specific format. Here, the passport number and nationality can be referenced from the aforementioned international resources.
[0191] Understandably, when the passport number is entered in an incorrect format, the form can mark the incorrect ID number, for example, but not limited to, highlighting it in red.
[0192] Step 108: Render the third-party edit code into the target form based on the renderer.
[0193] Specifically, before rendering the third editing code based on the renderer and the rendering form container, internationalization resources need to be loaded in advance. These internationalization resources can be loaded from the corresponding server based on the second editing code.
[0194] Furthermore, during the rendering of the third editing code based on the renderer and the rendering form container, the first descriptor code is first obtained in the third editing code, and the first descriptor can be processed by depth-first traversal to obtain the field descriptor corresponding to each field. The field descriptor can be used to check the visibility of the field.
[0195] It is possible that when the hidden field option of any field descriptor is detected to be enabled, it means that the field will not be displayed in the final generated form, but the field can be displayed when the information entered by the user meets the conditions, for example, but not limited to when the identity information is selected as ID number, the corresponding ID number input box can be displayed.
[0196] As another optional embodiment of this application, based on a renderer and a rendering form container, internationalization resources and third-edit code after the first hiding process are rendered into a target form, including:
[0197] Based on the renderer, the layout processing is performed on the components corresponding to the internationalized resources and the third-edit code after the first hiding process.
[0198] When it is detected that the internationalized resources and the fields of the third edit code after the first hiding process are not in the display area, the internationalized resources and the fields of the third edit code after the first hiding process are hidden in the display area.
[0199] Based on the renderer and the form container, the internationalized resources after the second hiding process and the third editing code are rendered into the target form.
[0200] Specifically, during the rendering of the third-level editing code based on the renderer and the rendering form container, the renderer can also perform layout operations on the internationalization resources and the corresponding components of the third-level editing code after the first hiding process. For example, but not limited to, the display area can be determined according to the layout requirements of the rendering form container. When it is detected that some internationalization resources and the fields of the third-level editing code after the first hiding process are not in the display area, the fields of the internationalization resources and the third-level editing code after the first hiding process can be hidden, which can be understood as not mounting the rendering object of the corresponding field component.
[0201] Furthermore, after hiding some internationalized resources and the fields of the third edit code after the first hiding process, the renderer can then render the hidden edit code.
[0202] It is understood that, in the embodiments of this application, the lazy characteristics of the Iterator can also be utilized, but not limited to, to avoid rendering invisible fields within the container, thereby improving the performance of the renderer.
[0203] As another optional embodiment of this application, based on a renderer and a rendering form container, the internationalized resources after the second hiding process and the third editing code are rendered into the target form, including:
[0204] The second descriptor code is obtained from the internationalized resources after the second hiding process and the third editing code, and the component options corresponding to the fields are determined in the second descriptor code;
[0205] The target form is obtained by rendering the field input component based on the renderer, the form container, and the component options corresponding to the field.
[0206] Specifically, during the rendering of the third editing code based on the renderer and the rendering form container, the renderer can also obtain the second descriptor from the internationalized resources after the second hiding process and the third editing code, and traverse the second descriptor to obtain the field descriptor corresponding to each field.
[0207] Furthermore, after obtaining the field descriptors from the second descriptor, the renderer can select a suitable rendering component based on the component options of the field descriptor, and combine this rendering component to render the field input component to obtain the target form. Here, the renderer can, but is not limited to, selecting a suitable rendering component based on the field's component options, and rendering the field input component according to the component_options. For example, FIELD_COMPONENT_DATE_TIME is a date and time selector, and the component option {"default": "now", "hideTime": true} indicates that the default time is the current time, and the time part can be hidden.
[0208] It is understood that, in the embodiments of this application, the renderer may also determine the style option corresponding to the field in the second descriptor code to perform style rendering on the field input component after rendering. For example, but not limited to, the renderer may assign a specific style to the rendered content according to the field_style option, which can achieve the effect of emphasizing or weakening the field.
[0209] It is understood that, in this embodiment of the application, the renderer can also perform field checks based on options such as validators, custom_validators, required, required_condition, max_size, min_size, size_condition, and default_size. The required option indicates that the field is mandatory, equivalent to validators containing FIELD_VALIDATOR_NOT_EMPTY. The required_condition option can be filled with an expression to specify when the required effect is needed under certain circumstances.
[0210] The `validators` option for a field can be filled with a set of predefined, parameterless validators, such as `FIELD_VALIDATOR_NOT_EMPTY` (not empty), `FIELD_VALIDATOR_ALPHA_NUMERIC` (alphanumeric only), `FIELD_VALIDATOR_EMAIL` (e-mail format), and `FIELD_VALIDATOR_URL` (URL format). The renderer has built-in predefined validators and their internationalization resources, which can correctly and user-friendly display errors when checks fail.
[0211] The max_size, min_size, size_condition, and default_size options for a field are applied to variable-length data types such as string, repeated, map, bytes, etc., or used in numeric types to indicate a limit on the length or size.
[0212] It should also be noted that, in this embodiment, the renderer can also, but is not limited to, format the value into a specific format based on the field's formatter and custom_formatter options to facilitate user viewing. For example, FIELD_FORMATTER_UPPER indicates that the value is formatted in uppercase. This formatting behavior is only used for interface display and is not used to modify the final serialized value of the field. Alternatively, the renderer can also, but is not limited to, provide auto-completion and alternatives when the user inputs based on the field's auto_completers option. The candidate content is lazily loaded and cached when inputting to reduce startup delay caused by loading.
[0213] In addition to one or more embodiments mentioned above, the linkage form generation method based on interface description language proposed in this application can use Antlr4b to write lexical analyzers and syntax parsers to implement expression interpreters and calculators for specific syntaxes. Furthermore, it can generate platform-specific interface code by writing protoc-plugin, so that the front-end and back-end can quickly obtain it.
[0214] Of course, the front-end form component fills the values into the form message instance in real time. Here, you can choose to serialize it as JSON, Text, or Binary. The corresponding back-end can directly use Protobuf to parse the form message into a form message instance based on the form message and the serialized JSON, Text, or Binary, so as to make full use of the serialization and deserialization functions of the interface description language.
[0215] Please see Figure 4 , Figure 4This illustration shows a schematic diagram of a linkage form generation device based on an interface description language, as provided in an embodiment of this application.
[0216] like Figure 4 As shown, the linked form generation device based on the interface description language may include at least an extended processing module 401, a first determining module 402, a second determining module 403, and a form generation module 404, wherein:
[0217] The extended processing module 401 is used to extend the processing of at least two form options according to preset form requirements;
[0218] The first determining module 402 is used to obtain the first editing code based on at least two form options after expansion processing; wherein the first editing code is written in an interface description language.
[0219] The second determining module 403 is used to add a second editing code corresponding to the internationalized resource prefix to the first editing code when at least two form options after the expansion process contain an internationalized resource prefix, so as to obtain a third editing code.
[0220] The form generation module 404 is used to render third-party edit code into the target form based on the renderer.
[0221] In some possible embodiments, the apparatus further includes:
[0222] When at least two form options after expansion contain internationalized resource prefixes, add a second edit code corresponding to the internationalized resource prefix to the first edit code to obtain a third edit code. Before rendering the third edit code into the target form based on the renderer, filter out the message renderer option from the at least two form options after expansion and determine the rendering form container based on the message renderer option.
[0223] The renderer renders the third-party edit code into the target form, including:
[0224] Based on the renderer and the form container, the third-party edit code is rendered into the target form.
[0225] In some possible embodiments, the form generation module specifically includes:
[0226] Load internationalization resources based on the second-edit code;
[0227] In the third editing code, the first descriptor code is obtained, and the fields of the first descriptor code are processed by depth-first traversal to obtain the field descriptor corresponding to each field in the first descriptor code;
[0228] When it is detected that the hidden field option of any field descriptor is enabled, the field corresponding to the field descriptor is first hidden;
[0229] Based on the renderer and the form container, internationalization resources and third-edit code that has undergone the first hiding process are rendered into the target form.
[0230] In some possible embodiments, the form generation module further includes:
[0231] Based on the renderer, the layout processing is performed on the components corresponding to the internationalized resources and the third-edit code after the first hiding process.
[0232] When it is detected that the internationalized resources and the fields of the third edit code after the first hiding process are not in the display area, the internationalized resources and the fields of the third edit code after the first hiding process are hidden in the display area.
[0233] Based on the renderer and the form container, the internationalized resources after the second hiding process and the third editing code are rendered into the target form.
[0234] In some possible embodiments, the form generation module further includes:
[0235] The second descriptor code is obtained from the internationalized resources after the second hiding process and the third editing code, and the component options corresponding to the fields are determined in the second descriptor code;
[0236] The target form is obtained by rendering the field input component based on the renderer, the form container, and the component options corresponding to the field.
[0237] In some possible embodiments, the form generation module further includes:
[0238] After rendering the field input component based on the renderer, the form container, and the component options corresponding to the field, the style options corresponding to the field are determined in the second descriptor code before the target form is obtained.
[0239] Based on the renderer, the form container, and the style options corresponding to the fields, the style of the field input component after rendering is applied to obtain the target form.
[0240] In some possible embodiments, the apparatus further includes:
[0241] Before rendering the field input component based on the renderer, the form container, and the component options corresponding to the field to obtain the target form, the autocomplete options corresponding to the field are determined in the second descriptor code.
[0242] Load the candidate field component corresponding to the autocomplete options;
[0243] After rendering the field input component based on the renderer, the form container, and the component options corresponding to the field to obtain the target form, it also includes:
[0244] When user input is detected, the candidate field component is rendered based on the renderer.
[0245] Those skilled in the art will clearly understand that the technical solutions of the embodiments of this application can be implemented by means of software and / or hardware. In this specification, "unit" and "module" refer to software and / or hardware that can independently complete or cooperate with other components to complete a specific function, wherein the hardware may be, for example, a field-programmable gate array (FPGA), an integrated circuit (IC), etc.
[0246] Please see Figure 5 , Figure 5 This illustration shows a structural schematic diagram of another linkage form generation device based on an interface description language provided in an embodiment of this application.
[0247] like Figure 5 As shown, the linkage form generation device 500 based on the interface description language may include at least one processor 501, at least one network interface 504, user interface 503, memory 505, and at least one communication bus 502.
[0248] The communication bus 502 can be used to realize the connection and communication of the above components.
[0249] The user interface 503 may include buttons, and the optional user interface may also include a standard wired interface or a wireless interface.
[0250] The network interface 504 may include, but is not limited to, Bluetooth modules, NFC modules, Wi-Fi modules, etc.
[0251] The processor 501 may include one or more processing cores. The processor 501 connects various parts within the interface description language-based linked form generation device 500 using various interfaces and lines. It executes instructions, programs, code sets, or instruction sets stored in memory 505, and calls data stored in memory 505 to perform various functions and process data within the interface description language-based linked form generation device 500. Optionally, the processor 501 may be implemented using at least one hardware form selected from DSP, FPGA, and PLA. The processor 501 may integrate one or more of the following: CPU, GPU, and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also be implemented as a separate chip without being integrated into the processor 501.
[0252] The memory 505 may include RAM or ROM. Optionally, the memory 505 may include a non-transitory computer-readable medium. The memory 505 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 505 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 505 may also be at least one storage device located remotely from the aforementioned processor 501. Figure 5 As shown, the memory 505, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a linked form generation application based on an interface description language.
[0253] Specifically, processor 501 can be used to call the linked form generation application based on interface description language stored in memory 505, and specifically perform the following operations:
[0254] Expand at least two form options according to the preset form requirements;
[0255] Based on at least two form options after expansion processing, obtain the first edit code; wherein the first edit code is written in an interface description language;
[0256] When at least two form options after expansion contain internationalized resource prefixes, add a second edit code corresponding to the internationalized resource prefix to the first edit code to obtain the third edit code;
[0257] The third-party edit code is rendered into the target form based on the renderer.
[0258] In some possible embodiments, when at least two form options after expansion contain internationalized resource prefixes, after adding a second edit code corresponding to the internationalized resource prefix to the first edit code to obtain a third edit code, before rendering the third edit code into the target form based on the renderer, the method further includes:
[0259] Filter the message renderer options from at least two form options after expansion processing, and determine the form container to render based on the message renderer options;
[0260] The renderer renders the third-party edit code into the target form, including:
[0261] Based on the renderer and the form container, the third-party edit code is rendered into the target form.
[0262] In some possible embodiments, the third-party edit code is rendered as the target form based on the renderer and the form container, including:
[0263] Load internationalization resources based on the second-edit code;
[0264] In the third editing code, the first descriptor code is obtained, and the fields of the first descriptor code are processed by depth-first traversal to obtain the field descriptor corresponding to each field in the first descriptor code;
[0265] When it is detected that the hidden field option of any field descriptor is enabled, the field corresponding to the field descriptor is first hidden;
[0266] Based on the renderer and the form container, internationalization resources and third-edit code that has undergone the first hiding process are rendered into the target form.
[0267] In some possible embodiments, based on the renderer and the form container, internationalization resources and third-edit code after the first hiding process are rendered into the target form, including:
[0268] Based on the renderer, the layout processing is performed on the components corresponding to the internationalized resources and the third-edit code after the first hiding process.
[0269] When it is detected that the internationalized resources and the fields of the third edit code after the first hiding process are not in the display area, the internationalized resources and the fields of the third edit code after the first hiding process are hidden in the display area.
[0270] Based on the renderer and the form container, the internationalized resources after the second hiding process and the third editing code are rendered into the target form.
[0271] In some possible embodiments, based on the renderer and the form container, the internationalized resources after the second hiding process and the third editing code are rendered into the target form, including:
[0272] The second descriptor code is obtained from the internationalized resources after the second hiding process and the third editing code, and the component options corresponding to the fields are determined in the second descriptor code;
[0273] The target form is obtained by rendering the field input component based on the renderer, the form container, and the component options corresponding to the field.
[0274] In some possible embodiments, after rendering the field input component based on the renderer, the form container, and the component options corresponding to the field, and before obtaining the target form, the process further includes:
[0275] The style options corresponding to the fields are determined in the second descriptor code;
[0276] Based on the renderer, the form container, and the style options corresponding to the fields, the style of the field input component after rendering is applied to obtain the target form.
[0277] In some possible embodiments, before rendering the field input component based on the renderer, the form container, and the component options corresponding to the field to obtain the target form, the following steps are included:
[0278] The autocomplete option corresponding to the field is determined in the second descriptor code;
[0279] Load the candidate field component corresponding to the autocomplete options;
[0280] After rendering the field input component based on the renderer, the form container, and the component options corresponding to the field to obtain the target form, it also includes:
[0281] When user input is detected, the candidate field component is rendered based on the renderer.
[0282] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method. The computer-readable storage medium may include, but is not limited to, any type of disk, including floppy disks, optical disks, DVDs, CD-ROMs, microdrives, as well as magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic cards or optical cards, nanosystems (including molecular memory ICs), or any type of medium or device suitable for storing instructions and / or data.
[0283] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0284] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0285] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some service interface; the indirect coupling or communication connection between apparatuses or units may be electrical or other forms.
[0286] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0287] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0288] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0289] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.
[0290] The above are merely exemplary embodiments of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of embodiments of this disclosure upon considering the specification and practicing the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described herein. The specification and embodiments are to be considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.
Claims
1. A method for generating linked forms based on an interface description language, characterized in that, include: Expand at least two form options according to the preset form requirements; Based on the at least two form options after expansion processing, a first editing code is obtained; wherein the first editing code is written in an interface description language. When the at least two form options after the expansion process contain an internationalized resource prefix, a second edit code corresponding to the internationalized resource prefix is added to the first edit code to obtain a third edit code; Filter the message renderer options from the at least two form options after the expansion process, and determine the rendering form container based on the message renderer options; Load internationalization resources based on the second edit code; In the third editing code, the first descriptor code is obtained, and the fields of the first descriptor code are subjected to a depth-first traversal to obtain the field descriptor corresponding to each field in the first descriptor code; When it is detected that the hidden field option of any of the field descriptors is active, the field corresponding to the field descriptor is subjected to the first hiding process; Based on the renderer and the rendering form container, the internationalization resources and the third edit code after the first hiding process are rendered into the target form.
2. The method according to claim 1, characterized in that, The step of rendering the internationalization resources and the third edit code after the first hiding process into the target form based on the renderer and the rendering form container includes: Based on the renderer, layout processing is performed on the components corresponding to the internationalized resources and the third edit code rendered after the first hiding process; When it is detected that the internationalized resource and the field position of the third edit code after the first hiding process are not in the display area, the internationalized resource and the field of the third edit code after the first hiding process that are not in the display area are subjected to a second hiding process; Based on the renderer and the rendering form container, the internationalization resources after the second hiding process and the third editing code are rendered into the target form.
3. The method according to claim 2, characterized in that, The process of rendering the internationalized resources (after the second hiding process) and the third edited code into the target form based on the renderer and the rendering form container includes: The second descriptor code is obtained from the internationalized resources after the second hiding process and the third editing code, and the component options corresponding to the fields are determined in the second descriptor code; Based on the renderer, the rendering form container, and the component options corresponding to the field, the field input component is rendered to obtain the target form.
4. The method according to claim 3, characterized in that, After rendering the field input component based on the renderer, the rendering form container, and the component options corresponding to the field, and before obtaining the target form, the process further includes: The style options corresponding to the fields are determined in the second descriptor code; Based on the renderer, the rendering form container, and the style options corresponding to the fields, the field input component after rendering is styled to obtain the target form.
5. The method according to claim 3, characterized in that, Before rendering the field input component based on the renderer, the rendering form container, and the component options corresponding to the field to obtain the target form, the method further includes: The autocomplete option corresponding to the field is determined in the second descriptor code; Load the candidate field component corresponding to the autocomplete option; After rendering the field input component based on the renderer, the rendering form container, and the component options corresponding to the field to obtain the target form, the method further includes: When a user's input action is detected, the candidate field component is rendered based on the renderer.
6. A linked form generation device based on an interface description language, characterized in that, include: The extended processing module is used to extend the processing of at least two form options according to preset form requirements; The first determining module is used to obtain a first editing code based on the at least two form options after expansion processing; wherein the first editing code is written in an interface description language; The second determining module is used to add a second editing code corresponding to the internationalized resource prefix to the first editing code when the at least two form options after the expansion processing contain an internationalized resource prefix, so as to obtain a third editing code. A form generation module is used to filter out message renderer options from the at least two form options after expansion processing, and determine the rendering form container based on the message renderer options; Load internationalization resources based on the second edit code; In the third editing code, the first descriptor code is obtained, and the fields of the first descriptor code are subjected to a depth-first traversal to obtain the field descriptor corresponding to each field in the first descriptor code; When it is detected that the hidden field option of any of the field descriptors is active, the field corresponding to the field descriptor is subjected to the first hiding process; Based on the renderer and the rendering form container, the internationalization resources and the third edit code after the first hiding process are rendered into the target form.
7. A linkage form generation device based on an interface description language, characterized in that, Including the processor and memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code stored in the memory to perform the steps of the method as described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer or processor, cause the computer or processor to perform the steps of the method as described in any one of claims 1-5.