对于FCK edit我尝试了2种方式:
一种是jsp标签导入 ,但我们写的页面是xhtml,标签用不了,尝试找资料去写标签,没成功。
第二种是javascript 方式,这种方式我现在有个问题就是我在每个textarea写一段js,还没想到写成工具调用,各位有时间可以想想。
现在说下具体的配置
1.
将FCKeditor_2.5.1解压缩,目录结构是 FCKeditor_2.5.1\fckeditor\editor
将目录editor复制到项目的WebRoot下的fck里面(WebRoot里面建一个目录 叫 fck ,名字随你取),
将目录fckeditor中的 fckconfig.js、fckeditor.js、fckstyles.xml、fcktemplates.xml拷贝到 fck里面
然后将FCKeditor-2.3.zip(java)压缩包中\web\WEB-INF\lib\目录下的两个jar文件拷到项目的\WEB-INF\ lib\目录下。
把其中的src目录下的FCKeditor.tld文件copy到工程的WEB-INF下面。
2. 配置web.xml文件,我直接贴我那个了:
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<!-- 此为文件浏览路径 -->
<param-value>/UserFiles/</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SimpleUploader</servlet-name>
<servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<!-- 此为文件上传路径,需要在WebRoot 目录下新建 UserFiles 文件夹 -->
<!-- 根据文件的类型还需要新建相关的文件夹 Image、 Flash -->
<param-value>/UserFiles/</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<!-- 此参数为是否开启上传功能 -->
<param-name>enabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFile</param-name>
<param-value></param-value>
</init-param>
<init-param>
<!-- 此参数为文件过滤,以下的文件类型都不可以上传 -->
<param-name>DeniedExtensionsFile</param-name>
<param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsImage</param-name>
<param-value>jpg|gif|jpeg|png|bmp</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsImage</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFlash</param-name>
<param-value>swf|fla</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFlash</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>/fck/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SimpleUploader</servlet-name>
<url-pattern>/fck/editor/filemanager/upload/simpleuploader</url-pattern>
</servlet-mapping>
3.更改fckconfig.js
对应的六个URL等的值替换成以下内容:
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=File' ;
FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;
FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;
4.就到页面了
先导入js, : <script type="text/javascript" src="#{adminAccountBean.contextPath}/fck/fckeditor.js"></script>
在对应的texarea 加上一段代码,只要关注javascript 那段:
<td class="edit-value">
<h:inputTextarea id="description" styleClass="textbox" value="#{adminJobEditBean.jobRow.description}" />
<script type="text/javascript">
var oFCKeditor = new FCKeditor('jobForm:description') ; <!-- 参数为textarea名字 -->
oFCKeditor.BasePath = "#{adminAccountBean.contextPath}/fck/" ; <!-- fck路径 -->
oFCKeditor.Height = 400;
oFCKeditor.ToolbarSet = "Default" ;
oFCKeditor.ReplaceTextarea();
</script>
</td>
posted on 2008-05-29 11:28
支得柱 阅读(469)
评论(0) 编辑 收藏 所属分类:
other