Jforum使用FCKeditor的两种方法
来源:互联网 发布:papi酱起诉被驳回知乎 编辑:程序博客网 时间:2024/05/29 10:30
Jforum论坛使用在线编辑器很不直观,如果字符加了修饰,要发表后才能看到效果,不能所见即所得,很不shuan,
Jforum使用FCKeditor的两种方法:
把FCKeditor下载解压到项目中,
1,使用java调用jspTag自定义标签创建fckeditor,这种方法要在java代码里引入fck,
首先在JForum.java引入包:
import freemarker.ext.jsp.TaglibFactory;
import freemarker.ext.servlet.FreemarkerServlet;
import freemarker.ext.servlet.HttpRequestHashModel;
import freemarker.ext.servlet.ServletContextHashModel;
import freemarker.template.DefaultObjectWrapper;
然后在JForum.java的207行加入下面代码
/****************
* add by dyhjjk 支持用户自定义标签*/
// include the context variables to enable Freemarker custom tag support
context.put(FreemarkerServlet.KEY_JSP_TAGLIBS, new TaglibFactory(this.getServletContext()));
DefaultObjectWrapper wrapper = new DefaultObjectWrapper();
context.put(FreemarkerServlet.KEY_APPLICATION, new ServletContextHashModel(this, wrapper));
context.put(FreemarkerServlet.KEY_REQUEST, new HttpRequestHashModel(req, res, wrapper));
页面中创建FCKeditor:
在post_form.htm的368行加入下面代码:
<#assign tmp="">
<#function bb>
<#if post?exists>
<#if quote?exists>
<#assign tmp="[quote="+quoteUser+"]"+post.text?html+"[/quote]">
<#else>
<#assign tmp=post.text?html>
</#if></#if>
<#return tmp>
</#function>
<@FCK.editor instanceName="message" height="300" toolbarSet="bbcode" value="${bb()}">
</@FCK.editor>
再把原先的BB_code删除掉;
2,第二种方法比较简单,
首先在post_form.htm中引入FCKeditor.js文件;用js创建FCKeditor,在post_form.htm添加下面代码:
window.onload=function(){
var fckEditor=new FCKeditor('message');
fckEditor.BasePath='${contextPath}/jforum/fckeditor_2.6.6/';
fckEditor.ToolbarSet="bbcode";
fckEditor.Width="100%";
fckEditor.Height="430";
fckEditor.ToolbarStartExpanded=false;
fckEditor.ReplaceTextarea();
}
在fckconfig.js中加入自定义工具栏:
FCKConfig.ToolbarSets["bbcode"] = [
['Source', 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteWord'],
['FitWindow', 'ShowBlocks', '-', 'About'],
['Undo', 'Redo', '-', 'SelectAll', 'RemoveFormat'],
'/',
['Bold', 'Italic', 'Underline'],
['OrderedList', 'UnorderedList', '-', 'Outdent'],
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyFull'],
['Link', 'Unlink'],
['Image','Smiley','Rule'],
['TextColor', 'BGColor']
];
上面是发表文章用的,用FCKeditor保存数据后,显示的时候不正常,因为JForum原来是用BB_CODE在表示的,
如加粗标签用[b][/b]表示,和html标签不一样,所以在显示的时候,在PostCommon.java中做了处理,现在用FCKeditor
来编辑,保存的数据标签和html标签一致,所以不需要做转化了,可以在PostCommon函数入口直接return掉,就ok
- Jforum使用FCKeditor的两种方法
- Jsp页面中使用fckeditor控件的两种方法
- 调用FCKeditor的两种方法
- fckeditor组件使用---fckeditor调用的三种方法1
- php fckeditor 上传文件(或图片)中文显示为乱码的解决方法(两种方法)
- asp.net中使用FCKeditor的方法
- jforum 论坛 的DOS漏洞,请使用的jforum赶快自行补救
- Fckeditor的使用--Fckeditor对象的属性
- FCKeditor的使用
- fckeditor 的使用
- FCKeditor的使用
- FCKeditor编辑器的使用
- FCKeditor的使用
- FCKEditor 的使用
- FCKEditor的使用
- FCKeditor的使用
- FCKeditor的使用
- FCKeditor的使用
- iOS 图形库CorePlot
- Swift-字典
- iOS8 tableview separatorInset cell分割线左对齐,ios7的方法失效了
- Swift-元组tuple
- 文件存储的实现-login登录案例1-内置存储
- Jforum使用FCKeditor的两种方法
- MySQL hash索引和btree索引的区别
- LeetCode Populating Next Right Pointers in Each Node
- eclipse自动提示卡死情况处理
- 入驻新家了,大家欢迎一下我吧!
- 父类方法与接口方法同名初探
- XML和HTML解析
- Python读unicode文件
- [leetCode] Combination Sum