org.apache.cocoon.acting
Class AbstractValidatorAction
java.lang.Object
|
+--org.apache.avalon.framework.logger.AbstractLoggable
|
+--org.apache.cocoon.acting.AbstractAction
|
+--org.apache.cocoon.acting.AbstractConfigurableAction
|
+--org.apache.cocoon.acting.ConfigurableComposerAction
|
+--org.apache.cocoon.acting.AbstractComplementaryConfigurableAction
|
+--org.apache.cocoon.acting.AbstractValidatorAction
- All Implemented Interfaces:
- Action, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.Loggable
- Direct Known Subclasses:
- FormValidatorAction, SessionValidatorAction
- public abstract class AbstractValidatorAction
- extends AbstractComplementaryConfigurableAction
- implements org.apache.avalon.framework.configuration.Configurable
Abstract implementation of action that needs to perform validation of
parameters (from session, from request, etc.). All `validator' actions
share the same description xml file. In such file every parameter is
described via its name, type and its constraints. One large description
file can be used among all validator actions, because each action should
explicitely specify which parameters to validate - through a sitemap
parameter.
<root>
<parameter name="username" type="string" nullable="no"/>
<parameter name="role" type="string" nullable="no"/>
<parameter name="oldpassword" type="string" nullable="no"/>
<parameter name="newpassword" type="string" nullable="no"/>
<parameter name="renewpassword" type="string" nullable="no"/>
<parameter name="id" type="long" nullable="no"/>
<parameter name="sallary" type="double" nullable="no"/>
<parameter name="theme" type="string" nullable="yes" default="dflt"/>
<constraint-set name="is-logged-in">
<validate name="username"/>
<validate name="role"/>
</constraint-set>
<constraint-set name="is-in-admin-role">
<validate name="username"/>
<validate name="role" equals-to="admin"/>
</constraint-set>
<constraint-set name="new-passwords-match">
<validate name="oldpassword"/>
<validate name="newpassword"/>
<validate name="renewpassword"
equals-to-param="newpass"/>
</constraint-set>
</root>
The types recognized by validator and their attributes
string | nullable="yes|no" default="str" |
long | nullable="yes|no" default="123123" |
double | nullable="yes|no" default="0.5" |
Default value takes place only when specified parameter is nullable and
really is null or empty. Long numbers may be specified in decimal, hex or
octal values as accepted by java.Lang.decode (String s).
Constraints
matches-regex | POSIX regular expression |
min-len | positive integer |
max-len | positive integer |
min | Double / Long |
max | Double / Long |
Constraints can be defined globally for a parameter and can be overridden
by redefinition in a constraint-set. Thus if e.g. a database field can take
at maximum 200 character, this property can be set globally.
The attributes recognized in "constraint-set"
equals-to-param | parameter name |
equals-to | string constant |
- Version:
- CVS $Id: AbstractValidatorAction.java,v 1.7 2002/03/21 04:09:19 vgritsenko Exp $
- Author:
- Martin Man, Christian Haul
Fields inherited from interface org.apache.cocoon.acting.Action |
ROLE |
Method Summary |
ValidatorActionHelper |
validateParameter(java.lang.String name,
org.apache.avalon.framework.configuration.Configuration constraints,
org.apache.avalon.framework.configuration.Configuration[] conf,
java.util.Map params,
boolean isString)
Try to validate given parameter. |
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.apache.avalon.framework.configuration.Configurable |
configure |
Methods inherited from interface org.apache.cocoon.acting.Action |
act |
AbstractValidatorAction
public AbstractValidatorAction()
validateParameter
public ValidatorActionHelper validateParameter(java.lang.String name,
org.apache.avalon.framework.configuration.Configuration constraints,
org.apache.avalon.framework.configuration.Configuration[] conf,
java.util.Map params,
boolean isString)
- Try to validate given parameter.
- Parameters:
name
- The name of the parameter to validate.constraints
- Configuration of all constraints for this parameter
as taken from the description XML file.conf
- Configuration of all parameters as taken from the
description XML file.params
- The map of parameters.isString
- Indicates wheter given param to validate is string
(as taken from HTTP request for example) or wheteher it should be
regular instance of java.lang.Double, java.lang.Long, etc.- Returns:
- The validated parameter.
Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.