JEECMS站群管理系统-- 标签的配置流程
以cms_content_list为例,首先,每一个标签的声明都是在jeecms-context.xml中进行的,
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">
……
<bean id="cms_content_list" class="com.jeecms.cms.action.directive.ContentListDirective"/>(声明标签对应的类)
<bean id="staticPageSvc" class="com.jeecms.cms.staticpage.StaticPageSvcImpl">
<property name="freeMarkerConfigurer">
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="freemarkerVariables">
<map>
……
<entry key="cms_content_list" value-ref="cms_content_list"/>
……
</map>
</property>
<property name="templateLoaderPath" value=""/>
……
</bean>
</property>
</bean>
</beans>
此外,在配置文件jeecms-servlet-front.xml中,还有一段对标签的配置
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="freemarkerVariables">
<map>
……
<entry key="cms_content_list" value-ref="cms_content_list"/>
……
</map>
</property>
……
</bean>
</bean>类ContentListDirective继承自AbstractContentDirective,最主要的是execute方法
public class ContentListDirective extends AbstractContentDirective {
/**
* 模板名称
*/
public static final String TPL_NAME = "content_list";
/**
* 输入参数,文章ID。允许多个文章ID,用","分开。排斥其他所有筛选参数。
*/
public static final String PARAM_IDS = "ids";
@SuppressWarnings("unchecked")
public void execute(Environment env, Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body) throws TemplateException, IOException {
//获取站点
CmsSite site = FrontUtils.getSite(env);
//获取内容列表,可以通过此处进行更改,获取自己数据库中的数据
List<Content> list = getList(params, env);
Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(
params);
//OUT_LIST值为tag_list,在类DirectiveUtils中声明,将内容列表放入其中
paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list));
//将params的值复制到variable中
Map<String, TemplateModel> origMap = DirectiveUtils
.addParamsToVariable(env, paramWrap);
//获取的是参数PARAM_TPL,是否调用模板以及调用的模板类型
InvokeType type = DirectiveUtils.getInvokeType(params);
//获取传入参数,列表样式,根据不同的参数获取不同的样式列表
String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params);
if (InvokeType.sysDefined == type) {
if (StringUtils.isBlank(listStyle)) {
throw new ParamsRequiredException(PARAM_STYLE_LIST);
}
//列表样式模板
env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);
} else if (InvokeType.userDefined == type) {
if (StringUtils.isBlank(listStyle)) {
throw new ParamsRequiredException(PARAM_STYLE_LIST);
}
//列表样式模板路径 WEB-INF\t\cms_sys_defined\style_list\style_2-1.html
FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);
} else if (InvokeType.custom == type) {
//这个模板就是自己声明的,即content_list.html,如果采用自定义模板的话,页面中可以只写上标签,并添加上标签内需要的几个参数,不需要写标签体的内容,会去自动调用模板中的标签体。
FrontUtils.includeTpl(TPL_NAME, site, params, env);
} else if (InvokeType.body == type) {
body.render(env.getOut());
} else {
throw new RuntimeException("invoke type not handled: " + type);
}
//将variable中的params值移除
DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);
}
@SuppressWarnings("unchecked")
protected List<Content> getList(Map<String, TemplateModel> params,
Environment env) throws TemplateException {
Integer[] ids = DirectiveUtils.getIntArray(PARAM_IDS, params);
if (ids != null) {
//根据内容ID数组获取文章列表
return contentMng.getListByIdsForTag(ids, getOrderBy(params));
} else {
return (List<Content>) super.getData(params, env);
}
}
@Override
protected boolean isPage() {
return false;
}
}
Content_list.html中的内容
[#list tag_list as a]
<li><a href="${a.url}" target="_blank">${a.title}</a></li>
[/#list]
就是简单的将tag_list中的内容,即“paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list));”中放入的数据遍历出来
style_2-1.html中的内容 主要是对图文列表或标题列表向上滚动的样式的,其中包含两个同样为样式的文件
style_2-1_core.html(图文列表或标题列表向上滚动)和style_1-1_core.html(图文列表或标题列表向上滚动),在此就不做赘述了。
Jeecms是基于Spring注解,在自定义标签时对于实体类和dao service等注意注解的问题。
JEECMS站群管理系统-- 标签的配置流程的更多相关文章
- JEECMS站群管理系统-- 标签使用和模板的制作
1模板规划 1.1资源文件 资源文件就是网页中用到的图片.CSS.JS等元素,在CMS系统中所有的资源文件在网站的根目录中的 /res_base/所属网站定义资源目录/TEMPLEATE/WEB /r ...
- JEECMS站群管理系统-- Jeecms安装过程
Jeecms是基于java技术研发的站群管理系统,稳定.安全.高效.跨平台.无限扩展是jeecms 的优点,系统支持mysql.oracle.sqlserver.db2等主流数据库. 轻松建设大规模网 ...
- JEECMS站群管理系统-- 自定义标签及使用自己创建的表的实现过程
下面是我自己定义的标签mycontent_list 首先,在数据库里创建了一个jc_mycontent的表,其中有id,title,content三个字段 其次,创建了一个实体类 public cla ...
- JEECMS站群管理系统-- 首页的加载过程
在浏览器中输入http://localhost:8080/jeecms,回车 首先进入配置文件web.xml, <context-param> <param-name>cont ...
- JEECMS站群管理系统-- Jeecms项目导入myeclipse
1.在myeclipse中新建一个项目jeecms,将服务器中jeecms项目下web-inf文件夹下内容拷到新建项目中 解压缩jeecms-3.0.2-final-src,在src文件夹下会看到有三 ...
- CMSZU站群管理系统 升级到 v1.8 [源码下载]
CmsZu 简介 CMSZU即CMS族,是个网站内容管理平台,基于PHP+MYSQL技术创建,源码开放. CmsZu 更新说明 V1.8 修改了些bug 完善数据库管理 -> 数据库表管理的 字 ...
- 备战双 11!蚂蚁金服万级规模 K8s 集群管理系统如何设计?
作者 | 蚂蚁金服技术专家 沧漠 关注『阿里巴巴云原生』公众号,回复关键词"1024",可获取本文 PPT. 前言 Kubernetes 以其超前的设计理念和优秀的技术架构,在容器 ...
- (转帖)开源容器集群管理系统Kubernetes架构及组件介绍
最近在搞Docker还有她的管理工具,选型Kuberetes后,被她的术语和概念搞得晕头转向...看了一篇文章还不错,放到这里分享出来. 地址:http://www.linuxidc.com/Linu ...
- 搭建Kubernetes容器集群管理系统
1.Kubernetes 概述 Kubernetes 是 Google 开源的容器集群管理系统,基于 Docker 构建一个容器的调度服务,提供资源调度.均衡容灾.服务注册.劢态扩缩容等功能套件. 基 ...
随机推荐
- c#链接postgresql
1.首先需要添加2个dll文件:Mono.Security.dll; Npgsql.dll. 2.配置文件增加 <appSettings> <!--<add key=" ...
- 在GridView控件FooterTemplate内添加记录 Ver3
重构此篇<在GridView控件FooterTemplate内添加记录 Ver2> http://www.cnblogs.com/insus/p/3270644.html 这有些缺陷,怎样 ...
- forEach,for in,for of循环的用法
一.一般的遍历数组的方法: var array = [1,2,3,4,5,6,7]; for (var i = 0; i < array.length; i) { console.log(i,a ...
- Common operators to overload-c++运算符重载的标准语法(全)
Common operators to overload Most of the work in overloading operators is boiler-plate code. That is ...
- 换根DP+树的直径【洛谷P3761】 [TJOI2017]城市
P3761 [TJOI2017]城市 题目描述 从加里敦大学城市规划专业毕业的小明来到了一个地区城市规划局工作.这个地区一共有ri座城市,<-1条高速公路,保证了任意两运城市之间都可以通过高速公 ...
- AtCoder - 2581 树状数组
You are given an integer sequence of length N, a= {a1,a2,…,aN}, and an integer K. a has N(N+1)⁄2 non ...
- CF796A Buying A House 模拟
Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains ...
- 21.Longest Palindromic Substring(最长回文子串)
Level: Medium 题目描述: Given a string s, find the longest palindromic substring in s. You may assume ...
- kuangbin专题十二 HDU1074 Doing Homework (状压dp)
Doing Homework Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- sublime侧边栏管理sidebarEnhancements浏览器设置
sidebarEnhancements是为了增强sublime Text侧边栏功能的一个插件,但是同时也可以实现设置浏览器浏览当前文件的功能. Ctrl+Shift+p 输入package contr ...