- 浏览: 127544 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
无敌洋葱头:
扯蛋吧,下载的东西不对
win7 安装memcached即使用 -
azhqiang:
谢谢,刚好没这个转义符弄的郁闷。
java split(".");注意事项 -
letry:
非常适合完全没有基础的step by step操作,谢谢!
Eclipse+maven+jetty开发环境搭建 -
kaaichongchong:
下载win版memcached的地址中下载出来的东西不对啊
win7 安装memcached即使用 -
atcompany:
太好了,正好用到了。。
java split(".");注意事项
1,下载FckEditor,解压,将FckEditor目录拷贝到项目的resource下(相应的精简请参考网上FckEdit配置说明),如:
src\main\resources\com\app\sys\components\fckeditor\FCKeditor_2.4.3
2,编写FckEditorModule和FckEditor类
代码如下:
FckEditor类:
package com.app.sys.components.fckeditor; import org.apache.tapestry.Asset; import org.apache.tapestry.MarkupWriter; import org.apache.tapestry.PageRenderSupport; import org.apache.tapestry.annotations.Environmental; import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.annotations.Path; import org.apache.tapestry.corelib.base.AbstractTextField; import org.apache.tapestry.ioc.annotations.Inject; import org.apache.tapestry.ioc.services.SymbolSource; import org.apache.tapestry.services.ClasspathAssetAliasManager; /** * * @author guanyq * */ public class FckEditor extends AbstractTextField { /** * The height of the editor */ @Parameter(defaultPrefix = "literal", value = "300px") private String height; /** * The width of the editor */ @Parameter(defaultPrefix = "literal", value = "100%") private String width; /** * The toolbar set to be used with this editor. Toolbar sets can be * configured in a {@link #customConfiguration custom configuration}. */ @Parameter(defaultPrefix = "literal") private String toolbarSet; /** * A custom configuration for this editor, see the fckeditor manual for * details on custom configurations. */ @Parameter private Asset customConfiguration; @Inject private ClasspathAssetAliasManager cpam; @Inject private SymbolSource symbolSource; public String getScript(String value) { value = value.replace('\r', '\\'); // this is needed for javascript to // be able to extend a string across // multiple lines value = value.replace("'", "'"); // this is needed because the // string delimiter is ' for the // script below return String.format("var oFCKeditor = new FCKeditor( '%s' );\n", getClientId()) + String.format("oFCKeditor.BasePath = '%s';\n", cpam.toClientURL(symbolSource.expandSymbols("${com.app.sys.components.fckeditorscript.path}")) + "/") + // todo could this be done in another way? (customConfiguration == null ? "" : String.format("oFCKeditor.Config[\"CustomConfigurationsPath\"] = '%s';\n", customConfiguration)) + (toolbarSet == null ? "" : String.format("oFCKeditor.ToolbarSet = '%s'\n", toolbarSet)) + String.format("oFCKeditor.Height = '%s';\n", height) + String.format("oFCKeditor.Width = '%s';\n", width) + String.format("oFCKeditor.Value = \'%s\';\n", value) + "oFCKeditor.Create() ;\n"; } @Environmental private PageRenderSupport _pageRenderSupport; @Inject @Path("${com.app.sys.components.fckeditorscript}/fckeditor.js") private Asset fckeditor; void beginRender(MarkupWriter writer) { _pageRenderSupport.addScriptLink(fckeditor); } @Override protected final void writeFieldTag(MarkupWriter writer, String value) { writer.element("script", "type", "text/javascript"); writer.writeRaw("<!--\n" + getScript(value) + "//-->\n"); } final void afterRender(MarkupWriter writer) { writer.end(); // script } }
FckEditorModule类:
package com.app.sys.components.fckeditor; import org.apache.tapestry.ioc.Configuration; import org.apache.tapestry.ioc.MappedConfiguration; import org.apache.tapestry.ioc.annotations.Symbol; import org.apache.tapestry.services.LibraryMapping; /** * FckEditor组件使用的Module * @author guanyq * */ public class FckEditorModule { public static void contributeFactoryDefaults( MappedConfiguration<String, String> configuration) { configuration .add("com.app.sys.components.fckeditorscript", "classpath:${com.app.sys.components.fckeditorscript.path}"); configuration .add("com.app.sys.components.fckeditorscript.path", "com/app/sys/components/fckeditor/FCKeditor_2.4.3"); } public static void contributeClasspathAssetAliasManager( MappedConfiguration<String, String> configuration, @Symbol("com.app.sys.components.fckeditorscript.path") String fckEditorScriptPath) { configuration.add("FCKeditor/", fckEditorScriptPath + "/"); } public static void contributeComponentClassResolver( Configuration<LibraryMapping> configuration) { configuration.add(new LibraryMapping("fckeditor", "com.app.sys.components.fckeditorscript")); } }
3,在SysModule中加载组件:
package com.app.sys.services; import java.io.IOException; import java.io.PrintWriter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tapestry.Link; import org.apache.tapestry.MarkupWriter; import org.apache.tapestry.internal.services.LinkFactory; import org.apache.tapestry.internal.services.PageMarkupRenderer; import org.apache.tapestry.internal.services.PageResponseRenderer; import org.apache.tapestry.internal.services.RequestPageCache; import org.apache.tapestry.internal.structure.Page; import org.apache.tapestry.ioc.MappedConfiguration; import org.apache.tapestry.ioc.OrderedConfiguration; import org.apache.tapestry.ioc.ServiceBinder; import org.apache.tapestry.ioc.annotations.InjectService; import org.apache.tapestry.ioc.annotations.SubModule; import org.apache.tapestry.ioc.annotations.Symbol; import org.apache.tapestry.services.ActionResponseGenerator; import org.apache.tapestry.services.ApplicationInitializer; import org.apache.tapestry.services.ApplicationInitializerFilter; import org.apache.tapestry.services.BindingFactory; import org.apache.tapestry.services.BindingSource; import org.apache.tapestry.services.ComponentClassResolver; import org.apache.tapestry.services.Context; import org.apache.tapestry.services.Dispatcher; import org.apache.tapestry.services.MarkupWriterFactory; import org.apache.tapestry.services.PageRenderRequestHandler; import org.apache.tapestry.services.Request; import org.apache.tapestry.services.RequestExceptionHandler; import org.apache.tapestry.services.RequestFilter; import org.apache.tapestry.services.RequestGlobals; import org.apache.tapestry.services.RequestHandler; import org.apache.tapestry.services.Response; import com.app.sys.common.exception.RedirectException; import com.app.sys.components.fckeditor.FckEditorModule; @SubModule( { FckEditorModule.class }) public class CsmModule { static Log log = LogFactory.getLog(CsmModule.class); /** * 系统启动时、绑定service * * @param binder */ public static void bind(ServiceBinder binder) { } /** * 初始化上下文 * * @param configuration */ public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration) { ApplicationInitializerFilter clearCaches = new ApplicationInitializerFilter() { public void initializeApplication(Context context, ApplicationInitializer initializer) { initializer.initializeApplication(context); } }; configuration.add("initialDataBase", clearCaches); } /** * PageResponseRenderer UTF-8编码 * * @param markupRenderer * @param markupWriterFactory * @param delegate * @return */ public static PageResponseRenderer decoratePageResponseRenderer(@InjectService("PageMarkupRenderer") final PageMarkupRenderer markupRenderer, @InjectService("MarkupWriterFactory") final MarkupWriterFactory markupWriterFactory, final Object delegate) { return new PageResponseRenderer() { public void renderPageResponse(Page page, Response response) throws IOException { MarkupWriter writer = markupWriterFactory.newMarkupWriter(); markupRenderer.renderPageMarkup(page, writer); PrintWriter pw = response.getPrintWriter("text/html; charset=UTF-8"); writer.toMarkup(pw); pw.flush(); } }; } /** * RequestFilter UTF-8编码 * * @param requestGlobals * @return */ public RequestFilter buildUtf8Filter(@InjectService("RequestGlobals") final RequestGlobals requestGlobals) { return new RequestFilter() { public boolean service(Request request, Response response, RequestHandler handler) throws IOException { requestGlobals.getHTTPServletRequest().setCharacterEncoding("UTF-8"); return handler.service(request, response); } }; } /** * contributeRequestHandler Utf8Filter * * @param configuration * @param timingFilter * @param encodingFilter */ public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration, @InjectService("Utf8Filter") final RequestFilter encodingFilter) { configuration.add("Utf8Filter", encodingFilter); // configuration.add("TimingFilter", timingFilter); } /** * 扩展binding source,实现一个list的绑定. * * @param configuration * @param bindingSource */ public static void contributeBindingSource(MappedConfiguration<String, BindingFactory> configuration, BindingSource bindingSource) { configuration.add("list", new ListBindingFactory(bindingSource)); } public void contributeMasterDispatcher(OrderedConfiguration<Dispatcher> configuration, PageRenderRequestHandler pageRenderRequestHandler, ComponentClassResolver componentClassResolver, @Symbol("tapestry.start-page-name") String startPageName, @InjectService("PageResponseRenderer") PageResponseRenderer pageResponseRenderer) { class RootPathDispatcherFix implements Dispatcher { private final ComponentClassResolver _componentClassResolver; private final PageRenderRequestHandler _handler; @SuppressWarnings("unused") private final PageResponseRenderer _renderer; private final String _startPageName; private final String[] _emptyContext = new String[0]; public RootPathDispatcherFix(final ComponentClassResolver componentClassResolver, final PageRenderRequestHandler handler, final PageResponseRenderer renderer, final String startPageName) { _componentClassResolver = componentClassResolver; _handler = handler; _renderer = renderer; _startPageName = startPageName; } public boolean dispatch(Request request, final Response response) throws IOException { // Only match the root path if (!request.getPath().equals("/")) return false; if (_componentClassResolver.isPageName(_startPageName)) { ActionResponseGenerator responseGenerator = _handler.handle(_startPageName, _emptyContext); if (responseGenerator != null) responseGenerator.sendClientResponse(response); return true; } return false; } } // Looks for the root path and renders the start page configuration.add("RootPathFix", new RootPathDispatcherFix(componentClassResolver, pageRenderRequestHandler, pageResponseRenderer, startPageName), "before:RootPath"); } // handle RedirectException /** * 异常处理 */ public static RequestExceptionHandler decorateRequestExceptionHandler(final Object delegate, final Response response, final RequestPageCache requestPageCache, final LinkFactory linkFactory, final ComponentClassResolver resolver) { return new RequestExceptionHandler() { public void handleRequestException(Throwable exception) throws IOException { // check if wrapped Throwable cause = exception; if (exception.getCause() instanceof RedirectException) { cause = exception.getCause(); } // check for redirect if (cause instanceof RedirectException) { // check for class and string RedirectException redirect = (RedirectException) cause; Link pageLink = redirect.getPageLink(); if (pageLink == null) { // handle Class (see ClassResultProcessor) String pageName = redirect.getMessage(); Class<?> pageClass = redirect.getPageClass(); if (pageClass != null) { pageName = resolver.resolvePageClassNameToPageName(pageClass.getName()); } // handle String (see StringResultProcessor) Page page = requestPageCache.get(pageName); pageLink = linkFactory.createPageLink(page, false); } // handle Link redirect if (pageLink != null) { response.sendRedirect(pageLink.toRedirectURI()); return; } } // no redirect so pass on the exception ((RequestExceptionHandler) delegate).handleRequestException(exception); } }; } }
4,编写FCKConfig.js(拷贝修改)
\src\main\resources\js\fckeditor\FCKConfig.js
内容:
FCKConfig.ToolbarSets["CommunityToolbarSet"] = [ ['Preview','-','Templates'], ['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], '/', ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'], ['OrderedList','UnorderedList','-','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], ['Link','Unlink','Anchor'], ['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'], '/', ['Style','FontFormat','FontName','FontSize'], ['TextColor','BGColor'], ['FitWindow','-','About'] ]; var FCKeditorAPI; function InitializeAPI(){ var A = window.parent; if (!(FCKeditorAPI = A.FCKeditorAPI)) { var B = 'var FCKeditorAPI = {Version : "2.4.3",VersionBuild : "15657",__Instances : new Object(),GetInstance : function( name ){return this.__Instances[ name ];},_FormSubmit : function(){for ( var name in FCKeditorAPI.__Instances ){var oEditor = FCKeditorAPI.__Instances[ name ] ;if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )oEditor.UpdateLinkedField() ;}this._FCKOriginalSubmit() ;},_FunctionQueue : {Functions : new Array(),IsRunning : false,Add : function( f ){this.Functions.push( f );if ( !this.IsRunning )this.StartNext();},StartNext : function(){var aQueue = this.Functions ;if ( aQueue.length > 0 ){this.IsRunning = true;aQueue[0].call();}else this.IsRunning = false;},Remove : function( f ){var aQueue = this.Functions;var i = 0, fFunc;while( (fFunc = aQueue[ i ]) ){if ( fFunc == f )aQueue.splice( i,1 );i++ ;}this.StartNext();}}}'; if (A.execScript) A.execScript(B, 'JavaScript'); else { if (FCKBrowserInfo.IsGecko10) { eval.call(A, B); } else if (FCKBrowserInfo.IsSafari) { var C = A.document; var D = C.createElement('script'); D.appendChild(C.createTextNode(B)); C.documentElement.appendChild(D); } else A.eval(B); }; FCKeditorAPI = A.FCKeditorAPI; }; FCKeditorAPI.__Instances[FCK.Name] = FCK; }; function _AttachFormSubmitToAPI(){ var A = FCK.GetParentForm(); if (A) { FCKTools.AddEventListener(A, 'submit', FCK.UpdateLinkedField); if (!A._FCKOriginalSubmit && (typeof(A.submit) == 'function' || (!A.submit.tagName && !A.submit.length))) { A._FCKOriginalSubmit = A.submit; A.submit = FCKeditorAPI._FormSubmit; } } }; function FCKeditorAPI_Cleanup(){ delete FCKeditorAPI.__Instances[FCK.Name]; }; FCKTools.AddEventListener(window, 'unload', FCKeditorAPI_Cleanup);
4,使用:
页面类中代码如下:
@Inject
@Path("classpath:/js/fckeditor/FCKConfig.js")
private Asset fckConfig;
/**
* @return Returns the fckConfig.
*/
public Asset getFckConfig() {
return fckConfig;
}
tml文件代码如下:
<span t:type="fckeditor/" t:id="content" height="310px" width="100%" customConfiguration="fckConfig" toolbarSet="AppToolbarSet"/>
页面类中通过content获取对应内容
发表评论
-
T5+spring2.0+hibernate3.2+xfire使用类库列表
2008-06-17 23:48 1997在eclipse3.2中新建maven项目(在eclipse添 ... -
T5中使用自定义SelectMultiple组件
2008-06-17 21:18 2724刚把东西都整理好了,已经贴进来了,不小心又给弄没了,气死我了, ... -
T5中使用DatePicker
2008-06-17 20:53 2677由于T5自带的时间控件感觉比较难看,特换成DatePicker ... -
T5+spring2.0+hibernate3.2使用OpenSessionInViewFilter
2008-06-17 20:07 1515按照网上讲的方法,在web.xml文件中加入filter,在页 ... -
Tapestry5 BeanModel分页实例
2007-11-15 20:22 41381、首先在实体包下建立实体类Book,代码如下: java 代 ... -
关于Tapestry5 初始化Module说明
2007-11-08 23:26 4373Tapestry5的系统初始化是由Module实现的,与ser ... -
Tapestry5 BeanEditForm 使用讲解
2007-11-06 18:37 4152实体类: java 代码 im ... -
Eclipse+maven+jetty开发Tapestry5实例
2007-11-03 16:19 5104还是word格式,请参见附件 -
Eclipse+maven+jetty开发环境搭建
2007-11-03 15:05 7011由于整理的是word文档,在此不作二次描述,请下载附件查看,过 ...
相关推荐
3. **引入到项目中**: 在需要使用FCKeditor的HTML页面中,通过`<script>`标签引入编辑器的核心JavaScript文件,通常是`fckeditor.js`。例如: ```html <script type="text/javascript" src="/editor/fckeditor.js...
要在MyEclipse中使用FCKeditor,首先需要下载FCKeditor的压缩包,然后将其解压到项目的WebContent目录下。接下来,在JSP文件中引入FCKeditor的JavaScript库,并配置相应的路径。在MyEclipse中,可以直接运行项目,...
在本文中,我们将深入探讨FCKEditor组件的使用方法,以及如何利用它来实现简单文章的编辑。 首先,我们需要了解FCKEditor的基本架构。FCKEditor主要由JavaScript库和服务器端支持组件组成。JavaScript部分负责在...
**FCKEditor完整使用说明** FCKeditor是一款强大的开源HTML编辑器,被广泛应用于网站内容管理系统(CMS)、论坛和其他需要富文本编辑功能的Web应用中。对于初学者来说,掌握其使用方法至关重要,因为这将极大地提升...
**JSP中使用FCKEditor** FCKEditor是一款在Web应用程序中广泛使用的开源富文本编辑器,它允许用户在浏览器端进行类似Word的文本编辑。在JSP(JavaServer Pages)环境中集成FCKEditor,可以极大地提升用户界面的交互...
FCKeditor组件的使用大大简化了Web应用中的文本编辑功能,为开发者提供了丰富的API和配置选项,使得定制和集成变得更加灵活。 FCKeditor的主要特点包括: 1. **多平台支持**:FCKeditor是跨平台的,可以在多种操作...
要在项目中使用FCKeditor,首先需要下载并解压FCKeditor的源代码包。手册中包含的"FCKeditor中文使用手册.exe"可能是安装程序或文档的电子版,用于详细解释安装步骤和配置选项。同时,"说明文件.txt"可能提供了额外...
在提供的压缩包文件“java中使用FCKEditor富文本编辑器”中,可能包含了这些必要的组件以及相关的示例代码和使用说明。 1. **集成步骤**: - 解压下载的FCKEditor包,将`fckeditor`目录复制到你的Web应用的`WEB-...
FCKEditor通常会被封装成一个EXT组件,以便在EXT的布局中使用。这涉及到创建一个新的EXT类,继承自EXT的基础组件,并实现与FCKEditor交互的方法。 集成步骤可能包括以下几点: 1. **引入FCKEditor资源**:下载并...
本文将详细介绍如何在ASP.NET MVC项目中集成并使用FCKeditor的MVC版本,以及JavaScript操作FCKeditor的一些基本方法。 首先,我们需要了解什么是ASP.NET MVC。ASP.NET MVC是一个模型-视图-控制器(Model-View-...
【标签】"easyf easy_" 指出这个集成是易于使用的,"EasyF"可能是FCKeditor在T5框架中的特定实现或者是一个简化版,目的是为了简化开发者的工作流程,使FCKeditor在T5中的配置和使用更加简单。 【压缩包子文件的...
若要将FCKeditor创建为HTML代码以便在其他模板引擎中使用,可以使用以下方法: ```php $output = $oFCKeditor->CreateHtml(); ``` 通过POST方式获取编辑器中的数据也非常简单,在`check.php`文件中使用如下代码...
FCKeditor 是一个基于JavaScript的开源富文本编辑器,它在Web开发领域中被广泛使用,尤其适用于那些需要提供用户友好、可视化的文本编辑功能的网站。FCKeditor 具备强大的功能,包括字体样式调整、图像处理、链接...
5. **易于集成**:描述中提到可以直接复制到项目中使用,这表明FCKeditor提供了简单直观的API和教程,使得与其他系统或框架的集成变得非常便捷。 6. **使用文档**:随FCKeditor提供的使用指南详细介绍了如何安装、...
在JSP中使用FCKeditor,首先需要将FCKeditor的JAR包引入到项目的类路径中。这些JAR包包含了FCKeditor的服务器端组件,如Servlet和相关的处理类,它们负责处理编辑器的上传和保存操作。 3. **FCKeditor的jar包** ...
在JSP环境中配置和使用FCKeditor涉及到一系列步骤,这个开源项目旨在提供一个强大的在线文本编辑器,使得Web应用程序能够具备类似MS Word的编辑功能。FCKeditor支持多种服务器端语言,包括Java,并且兼容IE 5+、...
- 为了兼容不同的浏览器,确保在JSP页面中使用XHTML标准。 - 如果在部署时遇到路径问题,检查FCKeditor的URL是否正确,确保所有相关文件可访问。 - 考虑安全问题,对用户提交的内容进行过滤和验证,防止XSS攻击。 ...
本文将详细介绍如何在PHP项目中配置和使用FCKeditor。 首先,你需要下载FCKeditor的最新版本。这个压缩包可能包含了“famfamfamAluminum”文件夹,这通常包含了编辑器使用的图标集,如工具栏上的各种功能图标。这些...
FCKeditor是一款历史悠久的开源富文本编辑器,它曾经是网页开发中广泛使用的文本域组件,允许用户在Web页面上编辑HTML内容,类似于桌面应用程序中的文字处理软件。然而,随着技术的发展和需求的变化,FCKeditor逐渐...
本文将围绕“Seam框架中使用FCKeditor”的主题进行详细探讨,结合给出的标签“源码”和“工具”,我们将深入理解如何在Seam项目中集成并使用FCKeditor,以及相关的依赖库。 Seam是一个Java EE框架,它整合了JSF...