org.chenillekit.tapestry.core.components
Class Editor

java.lang.Object
  extended by org.apache.tapestry5.corelib.base.AbstractField
      extended by org.apache.tapestry5.corelib.base.AbstractTextField
          extended by org.chenillekit.tapestry.core.components.Editor
All Implemented Interfaces:
ClientElement, Field

@Import(library="fckeditor/fckeditor.js")
public class Editor
extends AbstractTextField

The editor component provides a rich text editor as a form control. Based on the FCKeditor, the editor is highly configurable (and can therefore be complicated). This component aims to keep usage simple, outsourcing most of the configuration to an optional external javascript file.

The most important configurations are that of an external configuration file and the toolbars present in the editor. To support this, the editor component exposes the customConfiguration and toolbarSet parameters.

In the interest of usability, the editor component will function as classic textarea element.

NOTE: This component is built on the 2.x version of FCKeditor.

Version:
$Id: Editor.java 674 2010-07-29 12:47:25Z homburgs $
See Also:
FCKeditor developer's guide, FCKeditor user's guide

Constructor Summary
Editor()
           
 
Method Summary
protected  String getCustomizedConfigurationURL(Asset configurationAsset)
          FCK loads itself via an iframe, in which its own html file is loaded that takes care of bootstrapping the editor (which includes loading any custom config files).
protected  void writeFieldTag(MarkupWriter writer, String value)
           
 
Methods inherited from class org.apache.tapestry5.corelib.base.AbstractTextField
getWidth, ignoreBlankInput, isRequired, processSubmission
 
Methods inherited from class org.apache.tapestry5.corelib.base.AbstractField
createDefaultParameterBinding, decorateInsideField, getClientId, getControlName, getLabel, isDisabled, putPropertyNameIntoBeanValidationContext, removePropertyNameFromBeanValidationContext, setDecorator, setFormSupport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Editor

public Editor()
Method Detail

writeFieldTag

protected final void writeFieldTag(MarkupWriter writer,
                                   String value)
Specified by:
writeFieldTag in class AbstractTextField

getCustomizedConfigurationURL

protected String getCustomizedConfigurationURL(Asset configurationAsset)
FCK loads itself via an iframe, in which its own html file is loaded that takes care of bootstrapping the editor (which includes loading any custom config files). This html file is stored on the classpath and when it loads custom config files, it receives a relative name. The path of the html file is:

org/chenillekit/tapestry/core/components/fckeditor/editor/fckeditor.html

Now when that page is loaded in the iframe, it will load the configuration file by writing out a new script tag using the path it receives, which is relative. Because the path is relative tapestry interprets the config file to be a relative asset on the classpath (relative to the html file). So it looks for this on the classpath:

org/chenillekit/tapestry/core/components/fckeditor/editor/myeditor.js

Instead of something like:

/MyApp/myeditor.js

The following hack mangles the URL by appending the interpreted asset path to the (absolute) context path. This solves the problem for context and classpath assets.



Copyright © 2008-2010 ChenilleKit. All Rights Reserved.