Learn Extjs5 with me (29--add module and menu definition [2 build java Bean])

Source: Internet
Author: User

Learn Extjs5 with me (29--add module and menu definition [2 build java Bean])

create the corresponding bean file in Java for the 4 modules added in the previous section.         Once the above table is set up, you need to create a Java bean file. Several support classes need to be added before they can be built. first set up the package annotation in Com.jfok.server.common, then add two class libraries below, these two are custom annotation classes. The information for each module and the information for each field in the module are commented separately.
Package Com.jfok.server.common.annotation;import Java.lang.annotation.retention;import java.lang.annotation.retentionpolicy;/** * Used to annotate modules *  * @author Jiangfeng */@Retention (Retentionpolicy.runtime) Public @interface Tabledefine {//This table's ID number is a 4-bit numeric int ID (),//module name string title (),//module is referred to as String shortname () Default "";//Module The group name, String group (), whether the primary key of the module can be hierarchical, if it can be graded, can be defined as "2,2,2", indicating that there are three levels, each level of code is 2 bits,//such as ledger accounts can be defined//10//1001//100101//100102 100102//1002//... String codelevel () Default "";//whether the module has an attachment Boolean attachment () default false;}

Package Com.jfok.server.common.annotation;import Java.lang.annotation.retention;import java.lang.annotation.retentionpolicy;/** * is used to annotate each field in the module *  * @author Jiangfeng * *  /@Retention ( retentionpolicy.runtime) public @interface fielddefine {String title (); int number () default 0; String remark () Default ""; Boolean NameField () default False;boolean hidden () default false; String fieldgroup () defaults "Default group";}

Set up the package system in Com.jfok.server.hibernate, and put the bean files used by the systems in this directory. Create an interface file first:
Package com.jfok.server.hibernate.system;/** * has this interface class, is the control class of the system module *  * @author Jfok *  */public Interface _ Imodulecontrolinterface {}

Re-establish _modulegroup.java
Package Com.jfok.server.hibernate.system;import Java.io.serializable;import Javax.persistence.column;import Javax.persistence.entity;import Javax.persistence.id;import Com.jfok.server.common.annotation.fielddefine;import com.jfok.server.common.annotation.tabledefine;/** * Module grouping class, each module has a large class grouping * * @author jfok 2012.11.7 */@SuppressWarnings ("Serial") @Entity @org.hibernate.annotations.entity (dynamicupdate = True) @TableDefine (group = "System module", id = 9901, title = "Module grouping") public class _modulegroup implements _imodulecontrolinterface, Serializable {public static final String TITLE = "TF _title "; @Id @fielddefine (title =" Module Grouping ordinal ", Number = Ten) @Column (nullable = false, length = ten) Private String Tf_modulegroupi D; @FieldDefine (title = "Module Group name", NameField = true, Number =) @Column (nullable = false, length =) Private String tf_tit Le; @FieldDefine (title = "description", Number = +) private String tf_description; @FieldDefine (title = "icon Address", Number = +) Private S Tring Tf_iconurl; @FieldDefine (title = "Remark", Number = Private String tf_remark;public _modulegroup () {}/setter and Getter} 
In the above class, comments are made with a custom annotation class, one is the comment on the class name, and the other is the comment on each field. The function of these two-class annotations is to automatically add the information of these annotations to the table of saved modules and module fields when you add a module later.

Then join _module.java
Package Com.jfok.server.hibernate.system;import Java.io.serializable;import Javax.persistence.cascadetype;import Javax.persistence.column;import Javax.persistence.entity;import Javax.persistence.fetchtype;import Javax.persistence.id;import Javax.persistence.joincolumn;import Javax.persistence.manytoone;import Org.codehaus.jackson.map.annotate.jsonserialize;import Com.jfok.server.common.annotation.fielddefine;import com.jfok.server.common.annotation.tabledefine;/** * The meanings of each module in the system * * @author JFOK 2012.11.7 * */@JsonSerialize (include = J SonSerialize.Inclusion.NON_EMPTY) @SuppressWarnings ("Serial") @Entity @org.hibernate.annotations.entity ( DynamicUpdate = True) @TableDefine (group = "System module", id = 9902, title = "System Module") public class _module implements _imodulecontro Linterface, Serializable {public static final string ModuleID = "Tf_moduleid";p ublic static final String modulename = "Tf_ ModuleName "; @Id @fielddefine (title =" Module Id ", number = Ten) @Column (nullable = false, length = ten) Private String tf_mOduleid; Module ID, module ordinal @manytoone (cascade = cascadetype.refresh, fetch = Fetchtype.eager) @JoinColumn (name = "Tf_modulegroupid") @ Fielddefine (title = "Module Grouping", number =) private _modulegroup tf_modulegroup; @FieldDefine (title = "Module id", number =) @Colu MN (nullable = false, length =, updatable = false) private String tf_modulename; Module English name @fielddefine (title = "Module Name", NameField = true, Number = +) @Column (nullable = false, length =) Private String t F_title; Module Chinese name @fielddefine (title = "module abbreviation", number =) @Column (length =) private String tf_shortname; Abbreviation @fielddefine (title = "English abbreviation", Number = number) @Column (length =) private String tf_englishname; English abbreviation, in the new serial number, you can add this letter into the @fielddefine (title = "Table Name", Number = Seven) @Column (length =) Private String tf_tablename;@ Fielddefine (title = "PRIMARY Key", number = a) @Column (nullable = false, length =) Private String tf_primarykey;//module primary KEY @fielddefi NE (title = "Show Flag field", Number = Bayi) @Column (nullable = false, length =) Private String tf_namefields;//module mainKey content fields, such as contract name, Department name @fielddefine (title = "Record title TPL", Number =, remark = "If the display flag field cannot describe the record, you need to set this content") @Column ( Length = $) Private String tf_titletpl;//The main key content field of the module, such as the contract is the name of the contract, department is the department name @fielddefine (title = "coded Field", Number = 91) @ Column (length =) Private String tf_codefield;//the module encoding field, if any @fielddefine (title = "ordinal Field", Number = $) @Column (length = 5  0) Private string tf_orderfield;//the module encoding field, if any @fielddefine (title = "Date Field", Number = @Column) (length =) private string Tf_datefield; @FieldDefine (title = "Year Field", Number = Tf_yearfield) @Column (length =) Private String, @FieldDefine ( title = "Monthly Field", Number = 94) @Column (length =) private String Tf_monthfield; @FieldDefine (title = "Quarter Field", Number = @Col) Umn (length =) private string Tf_seasonfield; @FieldDefine (title = "File Field", Number = @Column) (length =) private string Tf_filefield; @FieldDefine (title = "Order on home page", Number = @Column (length =) private String tf_homepagetag; @FieldDefine ( title = "Module description", Number = +) @Column (length = number) PRIvate string tf_description; @FieldDefine (title = "Request Address", Number = () @Column (nullable = false, length =) Private String tf_requestmapping;//system in the backend service call access point User.do,employee.do etc @fielddefine (title = "icon Address", Number = +) @Column (length =) pr Ivate string Tf_iconurl; @FieldDefine (title = "Default Sort field", Number = *) private String Tf_defaultorderfield; @FieldDefine ( title = "Line Operation", Remark = "New and modified operations are done inline", Number = $) @Column (nullable = False) private Boolean tf_isinlineoper;//such as department Code 2, 2,2,2,2@fielddefine (title = "Coding Order", Remark = "If the encoding level is set, the primary key length must be in this order, and the parent encoding must exist", Number = @Column) (length = 50) String tf_codelevel; @FieldDefine (title = "Linkage module", Remark = "After the data additions and deletions in this module are changed, the open linkage module will refresh the data.") ", Number = 155) @Column (length = $) Private String Tf_linkedmodule; @FieldDefine (title =" Available ", Number = @Column) (Nullab Le = False) private Boolean tf_isenable = false; @FieldDefine (title = "Browsable", Number = @Column) (nullable = false) Private B Oolean Tf_hasbrowse = false; @FieldDefine (title = "can be added", number = @c)Olumn (nullable = False) Private Boolean Tf_hasinsert = False, @FieldDefine (title = "Modifiable", Number =) @Column (nullable = FA LSE) Private Boolean Tf_hasedit = False, @FieldDefine (title = "Can be deleted", Number = $) @Column (nullable = False) Private Boolean t F_hasdelete = false; @FieldDefine (title = "Executable", Number = @Column (nullable = False) Private Boolean tf_hasexec = false;@ Fielddefine (title = "Auditable", Number = () @Column (nullable = False) Private Boolean tf_hasauditing = false; @FieldDefine (titl E = "Approved", Number = +) @Column (nullable = False) Private Boolean Tf_hasapprove = false; @FieldDefine (title = "Payable", number = +) @Column (nullable = False) Private Boolean tf_haspayment = false; @FieldDefine (title = "There is an attachment", Number =) @Column (null able = false) Private Boolean tf_hasaddition = false; If you need an attachment @fielddefine (title = "Can be set", Remark = "User can set permissions on this module, the selected can browse and operate", Number = 260) @Column (nullable = false) Private B Oolean Tf_canlimit = false; Whether this module is able to set permissions @fielddefine (title = "Excel Import", Remark = "Can be excEl import new Record ", Number = +) @Column (nullable = False) Private Boolean Tf_allowinsertexcel = false; @FieldDefine (title =" Excel fix Change ", Remark =" Whether you can export the Excel modified and then import ", Number = 280) @Column (nullable = False) Private Boolean Tf_alloweditexcel = false; @FieldD Efine (title = "Can chart", Number = 290) @Column (nullable = False) Private Boolean Tf_haschart = false; @FieldDefine (title = "System Module" , number = Remark = "If the system module, the user does not have browse permissions, do not send the module definition to the front end") @Column (nullable = False) Private Boolean Tf_issystem = false; @Fie Lddefine (title = "Query Condition order Number", numbers = 310, remark = "This module is placed in the order of the conditional selection bar of the synthetic query") private Integer Tf_searchcondorder; @FieldDefine (title = "Remark", Number = +) Private String tf_remark;public _module () {}//setter and Getter}

_menugroup.java
Package Com.jfok.server.hibernate.system;import Java.io.serializable;import Java.util.list;import Javax.persistence.column;import Javax.persistence.entity;import Javax.persistence.id;import Javax.persistence.transient;import Com.jfok.server.common.annotation.fielddefine;import com.jfok.server.common.annotation.tabledefine;/** * Menu Group * * @author JFOK * * */@SuppressWarnings ("Serial") @ Entity@org.hibernate.annotations.entity (DynamicUpdate = True) @TableDefine (group = "System module", id = 9920, title = "Menu Grouping") public class _menugroup implements _imodulecontrolinterface, Serializable {@Id @fielddefine (title = "Sequence Number", Remark = "Menu grouping by The sequence number is displayed on the menu bar ", numbers = Ten) @Column (length = ten, Nullable = False) private String tf_menugroupid; @FieldDefine (title =" Group Name ", NameField = true, Number =) @Column (length =, nullable = False) private String Tf_title; @FieldDefine (title = "Unfold", REM Ark = "Expand by default under the Tree menu", number = +) Private Boolean Tf_expand; @FieldDefine (title = "Icon Glyph", Number = +) Private Boolean TF _glyph; @FieLddefine (title = "icon FileName", remark = "icon placed in/images/module/directory", number =) @Column (length =) Private String tf_iconurl;@f  Ielddefine (title = "Group description", Number = number) @Column (length =) private String tf_description; @FieldDefine (title = "Remarks", number = $) Private String Tf_remark; @Transientprivate list<_menumodule> tf_menumodules;public _menugroup () {}//setter and getter}

_menumodule.java
Package Com.jfok.server.hibernate.system;import Java.io.serializable;import Javax.persistence.cascadetype;import Javax.persistence.column;import Javax.persistence.entity;import Javax.persistence.fetchtype;import Javax.persistence.generatedvalue;import Javax.persistence.id;import Javax.persistence.joincolumn;import Javax.persistence.manytoone;import Org.codehaus.jackson.annotate.jsonignore;import Org.hibernate.annotations.genericgenerator;import Com.jfok.server.common.annotation.fielddefine;import com.jfok.server.common.annotation.tabledefine;/** * System can use menu item * * @author JFOK * * */@SuppressWarnings ("Serial") @ Entity@org.hibernate.annotations.entity (DynamicUpdate = True) @TableDefine (group = "System module", id = 9921, title = "System Menu")  public class _menumodule implements _imodulecontrolinterface, Serializable {@Id @fielddefine (title = "Id number", Hidden = True, Number = ten) @GeneratedValue (generator = "increment") @GenericGenerator (name = "Increment", strategy = "increment") Private Integer Tf_menumoduleid;@fIelddefine (title = "Sequence Number", Remark = "Show in menu in order", Number =) @Column (nullable = False) private Integer Tf_orderid; @JsonIgno Re@manytoone (cascade = cascadetype.refresh, fetch = Fetchtype.eager) @JoinColumn (name = "Tf_menugroupid", nullable = False) @FieldDefine (title = "Menu Grouping", NameField = true, Number = +) private _menugroup tf_menugroup; @JsonIgnore @manytoone ( Cascade = Cascadetype.refresh, fetch = Fetchtype.eager) @JoinColumn (name = "Tf_moduleid", nullable = False) @FieldDefine ( title = "System Module", Number = +) private _module tf_module; @FieldDefine (title = "Parent Menu title", Number =) @Column (length =) privat e String tf_parentmenu; @FieldDefine (title = "Separate Next", Number = number) private Boolean tf_addseparator; @FieldDefine (title = "Menu Title ", Number = All) @Column (length =) private string tf_title; @FieldDefine (title =" Parent module constraint setting ", Number = +) private string TF _parentfilter;//This field is used to transfer json to the foreground, placed in json @column (insertable = false, updatable = false) private String Tf_moduleid; Public _menumodule () {}//setter and getter}

Then modify the Hibernate.cfg.xml to add the above 4 classes to the configuration file.
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE hibernate-configuration Public "-//hibernate/hibernate configuration DTD 3.0//en" "Http://hibernate.sourcefor Ge.net/hibernate-configuration-3.0.dtd ">

So far, we've built the data tables and Java bean files, so we can develop the content of working together in front of the background.directory structure for each file:

Learn Extjs5 with me (29--add module and menu definition [2 build java Bean])

Related Article

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.