JEECMS Station Group Management System--the implementation process of customizing labels and using the tables you create

Source: Internet
Author: User

Here is my own definition of the label mycontent_list
First, a jc_mycontent table is created in the database with Id,title,content three fields
Second, an entity class was created

... Get Set method
}
Next, configure the configuration file for the Jc_mycontent table in hibernate

Persistent layer interfaces for interacting with databases

Persistence layer Implementation Class


Business Layer Interface

Business Layer Implementation Class


The abstract class of the label class, the most important is getdata this method, as well as the binding business layer, which can add a variety of query methods. Refer to Class Abstractcontentdirective

The most important class in the custom label inherits the abstract class above

public class Mycontentlistdirective extends Abstractmycontentdirective {/** * template name */public static final String Tpl_na ME = "Mycontent_list"; @SuppressWarnings ("unchecked") public void execute (Environment env, MAP params, templatemodel[] loopvars, Templatedirectivebody body) throws Templateexception, IOException {//get site Cmssite sites = frontutils.getsite (env);//Get content Listing list<mycontent> list = GetList (params, env); map<string, templatemodel> paramwrap = new hashmap<string, templatemodel> (params); The Out_list value is tag_list, where the table of contents is placed Paramwrap.put (myout_list, Default_wrapper.wrap (list)); Copy the value of the params to variable map<string, templatemodel> origmap = directiveutils.addparamstovariable (env, Paramwrap ); Not using the default template, directly using their own written simple template (mycontent_list.html) frontutils.includetpl (tpl_name, site, params, env); Remove the params value from the variable directiveutils.removeparamsfromvariable (env, Paramwrap, Origmap); } protected list<mycontent> GetList (map<string, templatemodel> params, ENVIronment env) throws Templateexception {return mycontentmng.getlist ();}}  


Style template mycontent_list.html content, inside can add some of their own style, can refer to \t\cms_sys_defined\style_list under the style file

Add the following code to the homepage.

[@cms_mycontent_list]    <ul class= "Topnews" >    

With these codes, you can query the data in your own table jc_mycontent and display it on the page

JEECMS Station Group Management System--the implementation process of customizing labels and using the tables you create

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.