jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class HTMLTextAreaWidget

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
All Implemented Interfaces:
java.lang.Cloneable, NodeGenerator, ResourceConsumer
Direct Known Subclasses:
EkitWidget

public class HTMLTextAreaWidget
extends TextAreaWidget
implements NodeGenerator

A textarea widget which knows how to convert text into a very basic HTML fragment.

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

Field Summary
static int BLOCK_TAG
          Tag type marker for block tags
static int EMPTY_TAG
          Tag type marker for empty tags
static int INLINE_TAG
          Tag type marker for inline tags
protected  java.lang.String[] permittedBlockTags
          HTML block tags we'll allow.
protected  java.lang.String[] permittedEmptyTags
          HTML empty tags we'll allow
protected  java.lang.String[] permittedInlineTags
          HTML inline tags we'll allow; I'm a bit doubtful about allowing 'a' and 'img'
 
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
HTMLTextAreaWidget(java.lang.String name, java.lang.String prompt, java.lang.String help)
          pass all args up the chain
HTMLTextAreaWidget(java.lang.String myname, java.lang.String myprompt, java.lang.String myhelp, int r, int c)
          pass all args up the chain
HTMLTextAreaWidget(java.lang.String myname, java.lang.String myprompt, java.lang.String myhelp, int r, int c, boolean h)
          Deprecated. dont't use the hardwrap flag, use wrap instead
 
Method Summary
 void allowTag(java.lang.String tag, int type)
          advise me to allow this tag.
protected  java.lang.String ampersandClean(java.lang.String text)
          check for unprotected ampersands
 void disallowTag(java.lang.String tag)
          advise me to disallow this tag
 java.lang.String getHelp(Context context)
          Specialisation - add a list of permitted tags
protected  void postProcess(Context context)
          convert angle brackets to character references for safe display
protected  void preProcess(Context context)
          check whether there are any tags in the existing text; if so, that's more or less OK (provided they're ones we allow and have accurate nesting etc).
protected  java.lang.String roughParse(java.lang.String text)
          roughly parse this text as (supposed) HTML and throw an exception if I see anything I don't recognise - don't attempt to error correct.
 
Methods inherited from class uk.co.weft.htform.TextAreaWidget
generateInnerHTML, getHeight, layout
 
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, onloadRequest, scriptRequest, 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

EMPTY_TAG

public static final int EMPTY_TAG
Tag type marker for empty tags

See Also:
Constant Field Values

BLOCK_TAG

public static final int BLOCK_TAG
Tag type marker for block tags

See Also:
Constant Field Values

INLINE_TAG

public static final int INLINE_TAG
Tag type marker for inline tags

See Also:
Constant Field Values

permittedBlockTags

protected java.lang.String[] permittedBlockTags
HTML block tags we'll allow. Our stack model is not rich enough to capture the fact that 'li' has to be in 'ol' or 'ul'. 'pre' and all table and form related stuff disallowed to prevent hostile users breaking page formatting. 'h1' and 'h2' disallowed because I'm assuming the output of this will never be the whole of the page layout, and that major headings will come from somewhere else.


permittedEmptyTags

protected java.lang.String[] permittedEmptyTags
HTML empty tags we'll allow


permittedInlineTags

protected java.lang.String[] permittedInlineTags
HTML inline tags we'll allow; I'm a bit doubtful about allowing 'a' and 'img'

Constructor Detail

HTMLTextAreaWidget

public HTMLTextAreaWidget(java.lang.String myname,
                          java.lang.String myprompt,
                          java.lang.String myhelp,
                          int r,
                          int c,
                          boolean h)
Deprecated. dont't use the hardwrap flag, use wrap instead

pass all args up the chain

See Also:
TextAreaWidget.wrap

HTMLTextAreaWidget

public HTMLTextAreaWidget(java.lang.String name,
                          java.lang.String prompt,
                          java.lang.String help)
pass all args up the chain


HTMLTextAreaWidget

public HTMLTextAreaWidget(java.lang.String myname,
                          java.lang.String myprompt,
                          java.lang.String myhelp,
                          int r,
                          int c)
pass all args up the chain

Method Detail

getHelp

public java.lang.String getHelp(Context context)
                         throws javax.servlet.ServletException
Specialisation - add a list of permitted tags

Overrides:
getHelp in class Widget
Throws:
javax.servlet.ServletException

allowTag

public void allowTag(java.lang.String tag,
                     int type)
              throws DataFormatException
advise me to allow this tag.

Parameters:
tag - the tag to allow
type - the type (EMPTY_TAG, BLOCK_TAG, INLINE_TAG) of this tag
Throws:
DataFormatException - if type is not recognised.
See Also:
EMPTY_TAG, BLOCK_TAG, INLINE_TAG

disallowTag

public void disallowTag(java.lang.String tag)
advise me to disallow this tag

Parameters:
tag - the tag to disallow

ampersandClean

protected java.lang.String ampersandClean(java.lang.String text)
check for unprotected ampersands

Parameters:
text - the text to be parsed
Returns:
the text passed, with unprotected ampersands replaced by character references

postProcess

protected void postProcess(Context context)
convert angle brackets to character references for safe display

Overrides:
postProcess in class Widget
See Also:
LinkTableWidget

preProcess

protected void preProcess(Context context)
                   throws DataFormatException
check whether there are any tags in the existing text; if so, that's more or less OK (provided they're ones we allow and have accurate nesting etc). If not, put paragraph tags at start and end and replace each double line feed with an end-para - start-para tag pair.

Overrides:
preProcess in class Widget
Parameters:
context - the Context of the service in which I'm called
Throws:
DataFormatException - if data fails validation test

roughParse

protected java.lang.String roughParse(java.lang.String text)
                               throws DataFormatException
roughly parse this text as (supposed) HTML and throw an exception if I see anything I don't recognise - don't attempt to error correct.

Parameters:
text - the text to be parsed
Returns:
the text passed, at this stage unaltered - later versions might try to tidy up a little
Throws:
DataFormatException - if it doesn't parse

jacquard 1.12.0 by The Web Engineering Factory and Toolworks