`
ddh9504
  • 浏览: 110980 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

一个FCKeditor例子(on SWF)

阅读更多
下面是一个关于FCKeditor的例子,望各位多提宝贵意见,谢谢

注:对于这个例子我只剪切了部分的主要的代码,并且这个工程是基于SWF之上的一个应用实例,以前有一种做法就是直接在IFRAME调用FCKeditor页面即可,但有些强大的功能就会受限,比如:上传的轷片存不到服务器端等等。所以现在换了另一种方式来解决这个问题

对于FCKeditor的JS和页面我就不贴出来了,只贴一些相关配置,并添上附件供参考,谢谢!

web.xml
--------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

 
 
    <!-- FCKeditor configuration begin  -->
 
  <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>
<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>false</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>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
  </servlet-mapping>
 
  <servlet-mapping>
    <servlet-name>SimpleUploader</servlet-name>
    <url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
  </servlet-mapping> 
 
  <!-- FCKeditor configuration end -->
 
 
</web-app>
********************************************


CateNewsEditAction.java

---------------------------------------------

package com.ihomey.aca.action.manage.food;

import java.io.File;
import java.util.Date;

import org.coreframework.annotation.Param;
import org.coreframework.web.upload.DefaultFileSaver;
import org.coreframework.web.upload.FileSave;
import org.coreframework.web.upload.FileUpload;
import org.coreframework.web.upload.UploadUtils;
import org.coreframework.web.upload.Uploader;
import org.coreframework.webflow.ActionUtils;
import org.coreframework.webflow.Form;
import org.coreframework.webflow.action.EditEntityFormAction;
import org.springframework.validation.Errors;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.webflow.Event;
import org.springframework.webflow.RequestContext;
import com.ihomey.aca.action.manage.it.EditBrandHistoryAction;
import com.ihomey.aca.entity.CateNews;
import com.ihomey.aca.service.CateNewsMgr;

/**
* <p>
* Title:添加与修改
* </p>
*
* <p>
* Description: BrandHistory 添加与修改操作
* </p>
*
* <p>
* Copyright: Copyright (c) 2007 10
* </p>
*
* <p>
* Company: DDH
* </p>
*
* @author Winner
* @version 2.0
*/
/*
* 美食美事
*/
@Form(objectClass = CateNews.class)
public class CateNewsEditAction extends EditEntityFormAction {

private CateNewsMgr cateNewsMgr;

public CateNewsMgr getCateNewsMgr() {
return cateNewsMgr;
}

public void setCateNewsMgr(CateNewsMgr cateNewsMgr) {
this.cateNewsMgr = cateNewsMgr;
}

/**
* 装载FORM,及初始化值操作
*
* @param context
*            RequestContext
* @return Event
* @throws Exception
*/
public Event setupForm(RequestContext context) throws Exception {
super.setupForm(context);
return success();
}

/**
* 保存操作事件
*
* @param context
*            RequestContext
* @return Event
* @throws Exception
*/
public Event save(RequestContext context) throws Exception {
CateNews cn = (CateNews) getFormObject(context);

Errors errors = getFormErrors(context);
if (cn != null) {
try {
EditBrandHistoryAction ebha = new EditBrandHistoryAction();
String content = ebha.reHtml(
context.getRequestParameters().get("content"), 5000).replace("'",
"''");
cn.setInfoContent(content);
cn.setPublishTime(new Date());

cateNewsMgr.saveCateNews(cn);
return success();
} catch (Exception e) {

return error();
}
}
}

}


********************************************

CateNewsEdit.jsp
--------------------------------------------
<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/brand_style.css">
<title>美食美事</title>

<script language="javascript" src="/fck/FCKeditor/fckeditor.js"></script>

</head>

<body style="margin: 50px 20px 20px 20px;">

<spring:bind path="cateNews.*">
<c:forEach var="error" items="${status.errorMessages}">
<B><FONT color=RED> <br>
<c:out value="${error}" /> </FONT></B>
</c:forEach>
</spring:bind>
<div class="title border"><c:if
test="${cateNews.cateNewsId==null}">
<c:out value="添加美事"></c:out>
</c:if> <c:if test="${cateNews.cateNewsId!=null}">
<c:out value="更新美事"></c:out>
</c:if></div>
<form action="food-mgr.htm" enctype="multipart/form-data" method="post">
<input type="hidden" name="_flowExecutionKey"
value="${flowExecutionKey}"> <input type="hidden"
name="_eventId" value="submit"> <c:if
test="${cateNews.cateNewsId!=null}">
<input type="hidden" name="cateNewsId"
value="${cateNews.cateNewsId}">
</c:if>
<table width="100%" border="0" cellpadding="0" cellspacing="1"
bgcolor="#FFFFFF">
<tr>
<td class="table" width="160" bgcolor="#d6dff7" valign="top"
align="right">美事标题</td>
<td class="table" valign="top"><input name="infoCaption" type="text"
size="30" value="${cateNews.infoCaption}" class="input1" /></td>
</tr>

<tr>
<td class="table" height="500" bgcolor="#d6dff7" align="right"
valign="top">美事内容</td>
<td class="table" valign="top">


<textarea name="content" id="content"
style="display: none">${cateNews.infoContent}</textarea>

<!--这个是用以前方法实现的,但不能直接把图片上传到服务器,所以这种方式不可取
<iframe
id="EditorDefault"
src="fck/FCKeditor/editor/fckeditor.html?InstanceName=Body&Toolbar=Default"
width="100%" height="300" frameborder="no" scrolling="no"></iframe>
-->
</td>
</tr>
<tr>
<td height="80" colspan="2" align="center" bgcolor="#E8F1FF">
<input type="submit" value="提交" width="60" height="27" border="0">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="取消" onClick="javascript:history.back();">
</td>
</tr>
</table>
</form>

window.onload = function()
{
// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.

var language = '<bean:write name="language"/>';
language = language.toLowerCase();

var sBasePath = '../../FCKeditor/';
var oFCKeditor = new FCKeditor( 'content' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.ToolbarSet = "Default";
oFCKeditor.Height = "500";
oFCKeditor.Width = "100%";
oFCKeditor.SkinPath = "../../FCKeditor/editor/skins/silver/";

if(language == 'zh_cn'){
oFCKeditor.Config["AutoDetectLanguage"] = "false";
oFCKeditor.Config["DefaultLanguage"] = "zh-cn";
}else{
oFCKeditor.Config["AutoDetectLanguage"] = "false";
oFCKeditor.Config["DefaultLanguage"] = "en";
}

oFCKeditor.ReplaceTextarea() ;
var oFCKeditor_en = new FCKeditor( 'content_en_us' ) ;
oFCKeditor_en.BasePath = sBasePath ;
oFCKeditor_en.ToolbarSet = "Default";
oFCKeditor_en.Height = "500";
oFCKeditor_en.Width = "100%";
oFCKeditor_en.SkinPath = "../../FCKeditor/editor/skins/silver/";

if(language == 'zh_cn'){
oFCKeditor_en.Config["AutoDetectLanguage"] = "false";
oFCKeditor_en.Config["DefaultLanguage"] = "zh-cn";
}else{
oFCKeditor_en.Config["AutoDetectLanguage"] = "false";
oFCKeditor_en.Config["DefaultLanguage"] = "en";
}

oFCKeditor_en.ReplaceTextarea() ;
}


</body>
</html>

************************************************


  • fck.rar (628.2 KB)
  • 下载次数: 404
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics