jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class EkitWidget

java.lang.Object
  extended byuk.co.weft.htform.ResourceConsumerImpl
      extended byuk.co.weft.domutil.NodeGeneratorImpl
          extended byuk.co.weft.htform.Widget
              extended byuk.co.weft.htform.TextAreaWidget
                  extended byuk.co.weft.htform.HTMLTextAreaWidget
                      extended byuk.co.weft.htform.EkitWidget
All Implemented Interfaces:
java.lang.Cloneable, NodeGenerator, ResourceConsumer

public class EkitWidget
extends HTMLTextAreaWidget

A widget for editing an HTML fragment which makes use of the Ekit WYSIWYG editing applet, if the browser will support it, and reverts to the classic HTMLTextAreaWidget where the browser won't. Ekit is a wonderful WYSIWYG HTML editing applet by Howard Kistler, published under LGPL.

Version:
$Revision: 1.1.2.5 $ This revision: $Author: simon $
Author:
Simon Brooke

Field Summary
static int BROWSER_CONFORMITY_GOOD
          the browser is presumed to support all the standards we need
static java.lang.String BROWSER_CONFORMITY_MAGIC_TOKEN
          a magic token on which we will cache the browser conformity level in the context
static int BROWSER_CONFORMITY_MSFT
          the browser is presumed to have Microsoft-like incompatibilities
static int BROWSER_CONFORMITY_NONE
          the browser cannot support Ekit at all
static int BROWSER_CONFORMITY_NSCP
          the browser is presumed to have old netscape-like incompatibilities
static int CHARHEIGHT
          the assumed height in pixels of a character in the default font (yes, madness, but it's really only a hint to help get the applet to fit into roughly the same space as the textarea)
static int CHARWIDTH
          the assumed width in pixels of a character in the default font (yes, madness, but it's really only a hint to help get the applet to fit into roughly the same space as the textarea)
static int EKITTOOLBARHEIGHT
          the assumed height in pixels of the EkitWidget's toolbar area.
 
Fields inherited from class uk.co.weft.htform.HTMLTextAreaWidget
BLOCK_TAG, EMPTY_TAG, INLINE_TAG, permittedBlockTags, permittedEmptyTags, permittedInlineTags
 
Fields inherited from class uk.co.weft.htform.TextAreaWidget
HARD_WRAP, NO_WRAP, rows, SOFT_WRAP, wrap
 
Fields inherited from class uk.co.weft.htform.Widget
ACTIONCSSCLASS, akprompt, attrs, CONTEXTATTRIBUTESSUFFIX, cssClass, DANGEROUSCSSCLASS, debug, DEFAULTTOKEN, dflt, form, generateAs, GENERATEASHTML, GENERATEASXFORM, GENERATEASXML, help, HELPTOKEN, immutable, ISIMMUTABLETOKEN, ISMANDATORYTOKEN, mandatory, MANDATORYCSSCLASS, maxVisibleSize, name, NAMETOKEN, OPTIONALCSSCLASS, PREVIOUSVALUESUFFIX, prompt, PROMPTTOKEN, size, SIZETOKEN, type, TYPETOKEN
 
Fields inherited from class uk.co.weft.domutil.NodeGeneratorImpl
namespaceURI
 
Fields inherited from class uk.co.weft.htform.ResourceConsumerImpl
resourceBundleName
 
Fields inherited from interface uk.co.weft.domutil.NodeGenerator
NAMESPACEURIMAGICTOKEN
 
Fields inherited from interface uk.co.weft.htform.ResourceConsumer
RESOURCEBUNDLEMAGICTOKEN
 
Constructor Summary
EkitWidget(java.lang.String name, java.lang.String prompt, java.lang.String help)
           
EkitWidget(java.lang.String myname, java.lang.String myprompt, java.lang.String myhelp, int r, int c)
           
 
Method Summary
protected  int browserConformity(Context context)
          Infer the conformity level of the client browser by examining its user agent string.
protected  int browserVersion(java.lang.String useragent, java.lang.String target)
          Find the major version nnumber of the browser 'target' that the string claims to identify
 Node generateInnerHTML(Document doc, Context context)
          For now, do nothing special.
 java.lang.String getHelp(Context context)
          We want standard Widget-like help unless BROWSER_CONFORMITY_NONE, in which case we want HTMLTextAreaWidget like help
 void layout(Context context, int tabIndex)
          If the browser claims to be able to play ball, print an applet tag surrounding the textarea tag
protected  void layoutParam(javax.servlet.ServletOutputStream out, java.lang.String name, java.lang.Object value)
          layout one applet parameter on this output stream
 java.lang.String onloadRequest(Context context)
          When the page is loaded we may need to decide which of the alternate widgets to reveal; and we may need to copy the value from the text area into the applet
protected  void postProcess(Context context)
          If we're not showing the applet, we need HTMLTextAreaWidget - style post-processing
protected  void preProcess(Context context)
          if it's come back from Ekit, chop off the html and head tags and rewrite body as div; otherwise, hand up to my parent for pre-insert processing
 java.lang.String scriptRequest(Context context)
          Return the name of a JavaScript file which contains appropriate client-side support for this widget
 
Methods inherited from class uk.co.weft.htform.HTMLTextAreaWidget
allowTag, ampersandClean, disallowTag, roughParse
 
Methods inherited from class uk.co.weft.htform.TextAreaWidget
getHeight
 
Methods inherited from class uk.co.weft.htform.Widget
clone, generate, generateAttributes, generateAttributes, generateHTML, generateHTMLPrompt, generateValue, generateXML, getContextAttribute, getCssClass, getName, getPrompt, getTabPlaces, getType, getWidth, init, layout, layout, layout, layoutAttribute, layoutAttributes, layoutValue, makeReady, maybeLayout, maybeLayout, onloadRequest, scriptRequest, setAttribute, setContextAttribute, setCssClass, setDebug, setDefault, setHelp, setImmutable, setMandatory, setMandatory, setName, setPrompt, setSize, setType
 
Methods inherited from class uk.co.weft.domutil.NodeGeneratorImpl
getNamespaceURI, setNamespaceURI
 
Methods inherited from class uk.co.weft.htform.ResourceConsumerImpl
getContextOrResource, getResource, getResourceOrContext, getResourceString, grs, grs
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.co.weft.domutil.NodeGenerator
generate, getName, getNamespaceURI, init, setDebug
 

Field Detail

BROWSER_CONFORMITY_NONE

public static final int BROWSER_CONFORMITY_NONE
the browser cannot support Ekit at all

See Also:
Constant Field Values

BROWSER_CONFORMITY_GOOD

public static final int BROWSER_CONFORMITY_GOOD
the browser is presumed to support all the standards we need

See Also:
Constant Field Values

BROWSER_CONFORMITY_MSFT

public static final int BROWSER_CONFORMITY_MSFT
the browser is presumed to have Microsoft-like incompatibilities

See Also:
Constant Field Values

BROWSER_CONFORMITY_NSCP

public static final int BROWSER_CONFORMITY_NSCP
the browser is presumed to have old netscape-like incompatibilities

See Also:
Constant Field Values

CHARWIDTH

public static final int CHARWIDTH
the assumed width in pixels of a character in the default font (yes, madness, but it's really only a hint to help get the applet to fit into roughly the same space as the textarea)

See Also:
Constant Field Values

CHARHEIGHT

public static final int CHARHEIGHT
the assumed height in pixels of a character in the default font (yes, madness, but it's really only a hint to help get the applet to fit into roughly the same space as the textarea)

See Also:
Constant Field Values

EKITTOOLBARHEIGHT

public static final int EKITTOOLBARHEIGHT
the assumed height in pixels of the EkitWidget's toolbar area. This is the actual height on my screen, but it will of course be font-dependent

See Also:
Constant Field Values

BROWSER_CONFORMITY_MAGIC_TOKEN

public static final java.lang.String BROWSER_CONFORMITY_MAGIC_TOKEN
a magic token on which we will cache the browser conformity level in the context

See Also:
Constant Field Values
Constructor Detail

EkitWidget

public EkitWidget(java.lang.String name,
                  java.lang.String prompt,
                  java.lang.String help)

EkitWidget

public EkitWidget(java.lang.String myname,
                  java.lang.String myprompt,
                  java.lang.String myhelp,
                  int r,
                  int c)
Parameters:
myname - name of this widget
myprompt - prompt for this widget
myhelp - help string for this widget
r - number of rows of the text area widget
c - number of columns of the text area widget
Method Detail

getHelp

public java.lang.String getHelp(Context context)
                         throws javax.servlet.ServletException
We want standard Widget-like help unless BROWSER_CONFORMITY_NONE, in which case we want HTMLTextAreaWidget like help

Overrides:
getHelp in class HTMLTextAreaWidget
Parameters:
context - the service context
Returns:
an appropriate help string
Throws:
javax.servlet.ServletException

generateInnerHTML

public Node generateInnerHTML(Document doc,
                              Context context)
                       throws GenerationException
For now, do nothing special. Get it working the old way first

Overrides:
generateInnerHTML in class TextAreaWidget
Parameters:
doc - the document being generated
context - the context in which it's being generated
Returns:
an element representing the TEXTAREA element only.
Throws:
GenerationException
See Also:
TextAreaWidget.layout(uk.co.weft.dbutil.Context, int), Widget.generateHTML(org.w3c.dom.Document, uk.co.weft.dbutil.Context)

layout

public void layout(Context context,
                   int tabIndex)
            throws javax.servlet.ServletException,
                   java.io.IOException
If the browser claims to be able to play ball, print an applet tag surrounding the textarea tag

Overrides:
layout in class TextAreaWidget
Parameters:
context - the service context
tabIndex - the tabindex to use, ot the tab index of my first sub-widget if I have more than one
Throws:
DataStoreException - I don't, but things which specialise me may
javax.servlet.ServletException - I don't, but things which specialise me may
java.io.IOException - if can't write to the output stream

onloadRequest

public java.lang.String onloadRequest(Context context)
                               throws java.lang.Exception
When the page is loaded we may need to decide which of the alternate widgets to reveal; and we may need to copy the value from the text area into the applet

Overrides:
onloadRequest in class Widget
Parameters:
context - the service context
Throws:
java.lang.Exception

scriptRequest

public java.lang.String scriptRequest(Context context)
                               throws java.lang.Exception
Return the name of a JavaScript file which contains appropriate client-side support for this widget

Overrides:
scriptRequest in class Widget
Parameters:
context - the service context
Returns:
a comma separated list of JavaScript files which must be loaded to support this widget
Throws:
java.lang.Exception

browserConformity

protected int browserConformity(Context context)
Infer the conformity level of the client browser by examining its user agent string. Obviously we can't be exhaustive here but we can look for common values. Cache the result on the context because it's expensive to compute. If we can't infer a browser conformity value we'll fall back to a bog standard HTMLTextAreaWidget, which is OK.

Parameters:
context - the service context
Returns:
an int representing the level of conformity of the client

browserVersion

protected int browserVersion(java.lang.String useragent,
                             java.lang.String target)
Find the major version nnumber of the browser 'target' that the string claims to identify

Parameters:
useragent - a useragent strong sent by a client
target - a browser that client might claim to be
Returns:
the major version number of that browser is claims to be, if it makes any such claim, else -1

layoutParam

protected void layoutParam(javax.servlet.ServletOutputStream out,
                           java.lang.String name,
                           java.lang.Object value)
                    throws javax.servlet.ServletException,
                           java.io.IOException
layout one applet parameter on this output stream

Parameters:
out - the stream
name - the parameter name
value - the parameter value
Throws:
javax.servlet.ServletException - unlikely
java.io.IOException - unlikely

postProcess

protected void postProcess(Context context)
If we're not showing the applet, we need HTMLTextAreaWidget - style post-processing

Overrides:
postProcess in class HTMLTextAreaWidget

preProcess

protected void preProcess(Context context)
                   throws DataFormatException
if it's come back from Ekit, chop off the html and head tags and rewrite body as div; otherwise, hand up to my parent for pre-insert processing

Overrides:
preProcess in class HTMLTextAreaWidget
Throws:
DataFormatException

jacquard 1.12.0 by The Web Engineering Factory and Toolworks