javascript
JSF seam 中使用UEditor
(寫在前邊:其實(shí)java ee項(xiàng)目中可用的富文本編輯器還是很多的,見仁見智的選擇吧,不一定非要用UEditor,還有很多優(yōu)秀的編輯器的,之前總結(jié)過。)
http://fex-team.github.io/ueditor/ (官方的文檔)
在官方文檔中沒有完善使用jsp的詳解,在谷歌上找到了幾個(gè)在jsp中應(yīng)用的例子。
下面列出:
1、chenmingang.diandian.com/post/2013-01-29/40049104272
2、www.daimami.com/web/217004.htm
3、duozhilin.blog.163.com/blog/static/184971504201331252444915/
4、www.cnblogs.com/fazstart/archive/2013/05/28/3104842.html
5、asialee.iteye.com/blog/1749341
(1)
我閱讀完文檔之后,參考著應(yīng)用,首先在項(xiàng)目的view目錄下建立一個(gè)ueditor目錄,然后在將解壓好的內(nèi)容復(fù)制進(jìn)來,
然后編輯view/ueditor目錄下的ueditor.config.js文件設(shè)置里面的URL...
在頁面里引用script
<script type="text/javascript"src="/playTest/view/ueditor/ueditor.config.js"></script> <script type="text/javascript"src="/playTest/view/ueditor/ueditor.all.js"></script>
然后在需要應(yīng)用富文本編輯的地方使用如下聲明:
<script name="content" id="container" type="text/plain"> 測(cè)試文字!!!</script><script type="text/javascript">var ue = UE.getEditor('container');</script>
注意路徑的書寫,以及語法的單引號(hào)和雙引號(hào)。
這只是初步的應(yīng)用,通過官方文檔的學(xué)習(xí),你可以設(shè)置更全面的功能。
我自己寫的外部的測(cè)試頁面可以應(yīng)用demo.html
<!DOCTYPE html> <html><head><meta charset="UTF-8" /><title> UEditor Test ! </title></head><body><script type="text/javascript" src="ueditor.config.js"></script><script type="text/javascript" src="ueditor.all.js"></script><script type="text/plain" id="container" name="content">zhe li xie ru ni de chu shi hua de wen zi </script><!-- Instantiated The Editor --><script type="text/javascript">var ue = UE.getEditor('container')//You can Pass some parameter in this method when you Instantiated the editor //like this var ue = UE.getEditor('container' , {autoHeight:false})</script></body> </html>
可是按上述配置弄到項(xiàng)目里不行,不知是什么原因,就是嘗試失敗了,因?yàn)闆]有還沒考慮使用文件上傳功能,所以也沒有把相應(yīng)的包放到項(xiàng)目的lib目錄下。正在排查中,這里記錄下來。希望有經(jīng)驗(yàn)的同志可以解決我的問題,解決不了的話,以后相應(yīng)的功能的話可能會(huì)考慮其他的富文本編輯器。
(2)使用富文本編輯器最有難度的地方是文件上傳等功能,文字編輯還是比較簡單的,這方面的用法,等我解決的了最基本的問題之后,會(huì)更新細(xì)化的。
+++++++++++++++++++++++++++++++++++++2014-9-9++++++++++++++++++++++++++++++++++
首先解決在頁面中實(shí)現(xiàn)不了編輯器的問題:
1、在使用審查元素的時(shí)候在控制臺(tái)提示js路徑不對(duì),應(yīng)該就是路徑的問題,將項(xiàng)目名改成application.xml 中<display>中寫的名字,因?yàn)槭欠诺絭iew中的,所以寫的路徑是/penglai/view/ueditor/但是這樣寫是不對(duì)的,因?yàn)閡editor默認(rèn)是在view目錄中的,所以應(yīng)該的路徑是penglai/ueditor/
2、另一個(gè)比較重大的問題是....項(xiàng)目使用的是xhtml頁面,在xhtml中使用JS代碼會(huì)出現(xiàn)各種問題,解決辦法就是將代碼放在<![[ ? ?]]>中,,,然后考慮到兼容問題,使用//注釋掉。
參考這幾個(gè)網(wǎng)址的介紹:www.cnblogs.com/sink_cup/archive/2010/01/14/javascript_CDATA_w3c.html
www.jb51.net/web/16170.html%20%20%20%20%20%20%20%20
supanccy2013.iteye.com/blog/2038464
關(guān)于文件上傳的功能日后再說,嘿嘿。。。。。
總結(jié)
以上是生活随笔為你收集整理的JSF seam 中使用UEditor的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python日志模块 超量处理_Pyth
- 下一篇: 各浏览器内核JS运行速度比较