|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.avalon.framework.logger.AbstractLoggable | +--org.apache.cocoon.xml.AbstractXMLProducer | +--org.apache.cocoon.xml.AbstractXMLPipe | +--org.apache.cocoon.transformation.AbstractTransformer | +--org.apache.cocoon.transformation.SimpleFormTransformer
Eliminates the need for XSP to use FormValidatorAction. Caveat: Select options need a value attribute to work correctly.
This transformer fills all HTML 4 form elements with values from an InputModule, e.g. request, with the same name. It handles select boxes, textareas, checkboxes, radio buttons, password and text fields, and buttons.
In addition, it handles FormValidatorAction results by selectively omitting <error/> elements. These elements need a "name" attribute corresponding to the name of the form element, and either a "when" or a "when-ge" attribute.
An error element is send down the pipeline if validation results are available and either the results equals the "when" attribute or the result is greater or equal to the "when-ge" attribute.
Names for validation results are "ok", "not-present", "error", "is-null", "too-small", "too-large", and "no-match" for the similar named values from ValidatorActionResult.
There need not to be an "error" element for every form element, multiple error elements for the same form element may be present.
To use this transformer, add the following to your transformation pipeline:
<map:transform type="simple-form"/>
Configuration elements:
input-module | (String) InputModule configuration, defaults to an empty configuration and the "request-param" module |
Sitemap parameters:
fixed | (boolean) Do not change values |
prefix | (String) Added to the input element's name |
suffix | (String) Added to the input element's name |
input | (String) InputModule name |
Example:
<input name="user.name" size="50" maxlength="60"/> <error name="user.name" when-ge="error">required</error>
Field Summary | |
protected org.xml.sax.helpers.AttributesImpl |
emptyAttributes
Empty attributes (for performance). |
protected int |
ignoreCount
nesting level of ignored elements |
protected boolean |
ignoreThis
ignored element needs closing tag |
protected static java.lang.String |
INPUT_MODULE_ROLE
|
protected static java.lang.String |
INPUT_MODULE_SELECTOR
|
protected org.apache.avalon.framework.component.ComponentManager |
manager
The Avalon ComponentManager for getting Components |
protected java.util.Map |
objectModel
The current objectModel of the environment |
protected org.apache.avalon.framework.parameters.Parameters |
parameters
The parameters specified in the sitemap |
protected Request |
request
The current Request object |
protected java.util.Stack |
stack
stack of ignored element names |
protected java.util.Map |
validationResults
current request's validation results (all validated elements) |
protected java.lang.Object[] |
values
current element's request parameter values |
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
contentHandler, lexicalHandler, xmlConsumer |
Fields inherited from interface org.apache.cocoon.transformation.Transformer |
ROLE |
Constructor Summary | |
SimpleFormTransformer()
|
Method Summary | |
void |
characters(char[] c,
int start,
int len)
Receive notification of character data. |
void |
compose(org.apache.avalon.framework.component.ComponentManager manager)
Avalon Composable Interface |
void |
configure(org.apache.avalon.framework.configuration.Configuration config)
Avalon Configurable Interface |
void |
endElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw)
Start processing elements of our namespace. |
void |
ignorableWhitespace(char[] c,
int start,
int len)
Receive notification of ignorable whitespace in element content. |
protected java.lang.String |
printAttributes(org.xml.sax.Attributes attr)
Generate string representation of attributes. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive notification of a processing instruction. |
void |
recycle()
Recycle this component. |
void |
setup(SourceResolver resolver,
java.util.Map objectModel,
java.lang.String src,
org.apache.avalon.framework.parameters.Parameters par)
Setup the next round. |
void |
skippedEntity(java.lang.String name)
Receive notification of a skipped entity. |
protected void |
startCheckableElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw,
org.xml.sax.helpers.AttributesImpl attributes)
Handle input elements that may have a "checked" attributes, i.e. checkbox and radio. |
void |
startElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw,
org.xml.sax.Attributes attr)
Start processing elements of our namespace. |
protected void |
startErrorElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw,
org.xml.sax.Attributes attr)
Handle error elements. |
protected void |
startInputElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw,
org.xml.sax.Attributes attr)
Handle input elements. |
protected void |
startNonCheckableElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw,
org.xml.sax.helpers.AttributesImpl attributes)
Handle input elements that may don't have a "checked" attributes, e.g. text, password, button. |
protected void |
startOptionElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw,
org.xml.sax.Attributes attr)
Handle option elements. |
protected void |
startSelectElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw,
org.xml.sax.Attributes attr)
Handle select elements. |
protected void |
startTextareaElement(java.lang.String uri,
java.lang.String name,
java.lang.String raw,
org.xml.sax.Attributes attributes)
Handles textarea elements. |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe |
comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, setDocumentLocator, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
setConsumer, setContentHandler, setLexicalHandler |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable |
getLogger, setLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.xml.sax.ContentHandler |
endDocument, endPrefixMapping, setDocumentLocator, startDocument, startPrefixMapping |
Methods inherited from interface org.xml.sax.ext.LexicalHandler |
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity |
Methods inherited from interface org.apache.cocoon.xml.XMLProducer |
setConsumer |
Field Detail |
protected static final java.lang.String INPUT_MODULE_ROLE
protected static final java.lang.String INPUT_MODULE_SELECTOR
protected int ignoreCount
protected boolean ignoreThis
protected java.util.Stack stack
protected java.lang.Object[] values
protected java.util.Map validationResults
protected Request request
protected java.util.Map objectModel
protected org.apache.avalon.framework.parameters.Parameters parameters
protected org.apache.avalon.framework.component.ComponentManager manager
protected org.xml.sax.helpers.AttributesImpl emptyAttributes
Constructor Detail |
public SimpleFormTransformer()
Method Detail |
public void configure(org.apache.avalon.framework.configuration.Configuration config) throws org.apache.avalon.framework.configuration.ConfigurationException
configure
in interface org.apache.avalon.framework.configuration.Configurable
public void setup(SourceResolver resolver, java.util.Map objectModel, java.lang.String src, org.apache.avalon.framework.parameters.Parameters par) throws ProcessingException, org.xml.sax.SAXException, java.io.IOException
resolver
- The current SourceResolverobjectModel
- The objectModel of the environment.src
- The value of the src attribute in the sitemap.par
- The parameters from the sitemap.public void recycle()
recycle
in interface org.apache.avalon.excalibur.pool.Recyclable
recycle
in class AbstractXMLProducer
public void compose(org.apache.avalon.framework.component.ComponentManager manager)
compose
in interface org.apache.avalon.framework.component.Composable
manager
- The Avalon Component Managerprotected java.lang.String printAttributes(org.xml.sax.Attributes attr)
protected void startCheckableElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.helpers.AttributesImpl attributes) throws org.xml.sax.SAXException
protected void startNonCheckableElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.helpers.AttributesImpl attributes) throws org.xml.sax.SAXException
protected void startInputElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
protected void startSelectElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
protected void startOptionElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
protected void startTextareaElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
protected void startErrorElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
public void startElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attr) throws org.xml.sax.SAXException
startElement
in class AbstractXMLPipe
uri
- The namespace of the element.name
- The local name of the element.raw
- The qualified name of the element.attr
- The attributes of the element.public void endElement(java.lang.String uri, java.lang.String name, java.lang.String raw) throws org.xml.sax.SAXException
endElement
in class AbstractXMLPipe
uri
- The namespace of the element.name
- The local name of the element.raw
- The qualified name of the element.public void characters(char[] c, int start, int len) throws org.xml.sax.SAXException
characters
in class AbstractXMLPipe
c
- The characters from the XML document.start
- The start position in the array.len
- The number of characters to read from the array.public void ignorableWhitespace(char[] c, int start, int len) throws org.xml.sax.SAXException
ignorableWhitespace
in class AbstractXMLPipe
c
- The characters from the XML document.start
- The start position in the array.len
- The number of characters to read from the array.public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in class AbstractXMLPipe
target
- The processing instruction target.data
- The processing instruction data, or null if none was
supplied.public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
skippedEntity
in class AbstractXMLPipe
name
- The name of the skipped entity. If it is a parameter
entity, the name will begin with '%'.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |