Wmframework V2.0 Manual (2) System Code Generation

Source: Internet
Author: User

1. General Introduction
Wmframework implements a database-Based SystemCodeThere are two methods to automatically generate and complete code: the Web Code Automatic Generation System and the plug-in installation method. Here we advocate the use of the latter;
Automatically generated file types are as follows: domain (pojo), mapping, sql-map-conf.xml, JSP, Dao, spring configuration file, struts2 configuration file, custom generation is not recommended for Dao, spring, and struts2 configuration files, because the system has implemented a process framework;
You can customize JSP templates based on customer or system requirements. For headers such as XML and java files, the format content can also be customized.

2. Method 1: Automatic Web Code Generation System

A self-developed web Code Generation System Based on wmframework providesProgramRemote Access, select and confirm that the current data table needs to be generated. The entire code generation process is handled by the Code Generation System in a unified manner, and URL links are provided for real-time download.
Main operation objects:
Com. wmframework. codegen. modulegenerator code generation execution Interface
Com. wmframework. codegen. convert data conversion object
Com. wmframework. codegen. Replace. filereplace file replacement object
Com. wmframework. codegen. Replace. templereplace


transmission background string format description
* fnstr reference format: fn1 -- FN2 --... FNN
* format: fieldname-fieldvalue-type-optionname-Vos-vo-functionname
* 0 1 2 3 4 5 6
* Desc: field name-field Chinese name-element type-drop-down set-Vos object-vo Object ID-execution function
* example: User Name-0-null-oauser-user1-insertuser

2.1 query page generation
 
EnterHttp: // 192.168.0.58: 8080/autocode/On the home page, click to generate on the query page. After selecting an operation data table, the system automatically displays "query condition column", "query result column", and "query result data object, make sure that the query conditions and query result columns are correctly selected, and check whether the currently generated execution functions are consistent with the names in sqlmap.


The template generated on the query page is webroot/Temple/listtmp. jsp.


2.2 Edit page generation

EnterHttp: // 192.168.0.58: 8080/autocode/On the homepage, click Generate on the "edit" Page. After selecting an operation data table, the system automatically displays "select new content column" and "Data Object". Make sure that the columns you want to edit are correctly selected, check whether the currently generated execution function is the same as the name in sqlmap.


Edit the page to generate a template: webroot/Temple/addtmp. jsp


2.3 view page generation

EnterHttp: // 192.168.0.58: 8080/autocode/On the homepage, click Generate To Go To The details page. After selecting an operation data table, the system automatically displays "Select Detail display columns" and "result data object". Make sure that the columns you want to edit are correctly selected, check whether the currently generated execution function is the same as the name in sqlmap.


Template generated on the details page: webroot/Temple/detailtmp. jsp

3. Method 2: plug-in Code Generator

The wmframework code generator is mainly rewritten based on the ibatis plug-in ibator.

    • Usage mode

Install the plug-in based on myeclipse.

    • File Type

Currently the file types that can be automatically generated are as follows: domain, mapping, sql-map-conf.xml, JSP, Dao, spring configuration file, struts2 configuration file (not advocate, the current system architecture has a general action ), template customization exists on the JSP page.

    • Generation Method

Multi-Project (all projects are generated at a time), full database (all data tables are generated at a time), custom tables (custom data tables need to be generated)

A simple configuration file is as follows:

<? XML version = "1.0" encoding = "UTF-8"?> <! Doctype ibatorconfiguration public "-// Apache Software Foundation // DTD Apache ibatis ibator configuration 1.0 // en" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd"> <ibatorconfiguration> <! -- The current plug-in uses the serial number --> <license serialno = "plugin"/> <! -- Load the current database driver package --> <classpathentrylocation = "D:/wmworkspace/ibator/webroot/WEB-INF/lib/mysql-connector-java.jar"/> <! -- Define the current context flag, that is, multiple projects are currently provided to generate at the same time --> <ibatorcontext id = "context1" projectid = "Wm"> <! -- Define contextid (required), Current Project ID (optional, default: System Architecture (WM) --> <! -- Engineering file (XML, JSP, JS, Java, properties, etc.) annotation definition, here we can expand or customize it ourselves --> <commentgenerator> <property name = "title" value = "Copyright (c) 2010 wmframework developed by our team"/> <! -- File Header --> <property name = "Description" value = ""/> <! -- Function description of the current file --> <property name = "author" value = "warison"/> <! -- Author --> <property name = "email" value = "warison@126.com"/> <! -- Contact Information --> <property name = "verison" value = "2.0"/> <! -- Current version --> </commentgenerator> <! -- Database connection JDBC Method definition --> <jdbcconnection driverclass = "com. MySQL. JDBC. Driver" connectionurl = "JDBC: mysql: // localhost: 3306/test? Useunicode = true & characterencoding = UTF-8 "userid =" root "Password =" WSC "dbtype =" MySQL "Remarks =" true "/> <! -- Optional; database type (Oracle, MySQL, DB2, sqlserver, cloudscape, Derby, HSQLDB, Sybase, db2_mf). The value is case insensitive. --> <! -- <Jdbcconnection driverclass = "oracle. JDBC. driver. oracledriver "connectionurl =" JDBC: oracle: thin: @ 192.168.0.181: 1521: zfaq "userid =" aqgl "Password =" elink2010 "dbtype =" oracle "Remarks =" true "/> --> <! -- Data model generation definition --> <javamodelgenerator targetpackage = "com. Client. domains" targetproject = "D: \ wmworkspace \ ibator \ SRC" encoding = "UTF-8"> <! -- Project path (absolute path. You must specify context when using plug-ins), data model storage path, and file encoding method (optional, not recommended) --> <! -- Define <javamodelgenerator targetpackage = "com. domains "targetproject =" ibator "> --> <property name =" rootclass "value =" com. base. parentdomain "/> <! -- Data Model parent class definition --> </javamodelgenerator> <! -- Ibatis sqlmap generation definition --> <sqlmapgenerator targetpackage = "com. Client. mappings" targetproject = "D: \ wmworkspace \ ibator \ SRC" encoding = "UTF-8"/> <! -- Project path (absolute path. You must specify context when using plug-ins), data model storage path, and file encoding method (optional, not recommended) --> <! -- Define <javamodelgenerator targetpackage = "com. Client. mappings" targetproject = "ibator"> --> <! -- JSP page generation settings --> <jspgenerator targetpackage = "com. client. JSP "targetproject =" D: \ wmworkspace \ ibator \ SRC "templepackage =" "/> <daogenerator targetpackage =" com. client. daos "targetproject =" D: \ wmworkspace \ ibator \ SRC "type =" GENERIC-SI "/> <! -- Has been blocked and generated --> <! -- All databases are generated at one time, and all attributes are configured by default --> <! -- <Alltable/> --> <! -- Customizable table generation. The following definitions need to generate a table --> <Table tablename = "A" domainobjectname = "adomain"> <! -- Optional definition item: listqryflds query condition field listresultflds query result field isidx whether serial number column ischeck is required to select a column --> <jsplist listqryflds = "user_id, user_name" listresultflds = "user_id, user_name "isidx =" false "ischeck =" false "> </jsplist> <! -- Optional definition item: view the display field in detailflds --> <jspdetail detailflds = "user_id, user_name"> </jspdetail> <! -- Optional definition items: addflds adds and modifies display fields --> <jspadd addflds = "user_id, user_name"> </jspadd> </table> <! -- <Table tablename = "sub_a"/> --> <! -- <Table tablename = "A" domainobjectname = "adomain"> --> <! -- Tablename: data table name, data model alias definition --> <! -- Optional. Primary Key Generation definition. In fact, a field is also supported, not necessarily PK --> <! -- Sqlstatement in the form of key generated by database SQL: It can be defined as a database type (DB2, MySQL, sqlserver, cloudscape, Derby, HSQLDB, Sybase, db2_mf) or an executable SQL statement identity: whether to return the current generated ID type: pre \ post --> <! -- <Generatedkey column = "user_id" sqlstatement = "selectseq_user_key.nextvalue from dual" Identity = "false"> </generatedkey> <generatedkey column = "user_id" sqlstatement = "MySQL" Identity =" false "> </generatedkey> --> <! -- Classkey without parameter format --> <! -- <Classkey column = "user_id" classname = "test. util. generateserial" methodname = "getuuid" Identity = "false"> </classkey> --> <! -- With the parameter format --> <! -- <Classkey column = "user_id" classname = "test. util. generateserial "methodname =" getuuid "Identity =" false "ARGs =" 1, 2 "paramtypes =" Java. lang. string, int "> </classkey> </table> --> </ibatorcontext> </ibatorconfiguration>

Contact Us

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

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

A Free Trial That Lets You Build Big!

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

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

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