org.mmbase.applications.editwizard
Class Validator

java.lang.Object
  extended by org.mmbase.applications.editwizard.Validator

public class Validator
extends Object

This class validates pre-html documents for the EditWizard. It is mainly used to register invalid form and fields.

Since:
MMBase-1.6
Version:
$Id: Validator.java 35335 2009-05-21 08:14:41Z michiel $
Author:
Kars Veling, Pierre van Rooden
Javadoc:

Constructor Summary
Validator()
           
 
Method Summary
static void addValidationError(Node validationnode, int errortype, String errormsg)
          This method adds a validation error to the form.
static void createStepsOverview(Document prehtml, Document schema)
          Constructs an overview-node in the pre-html where all steps are described.
static boolean validate(Document prehtml, Document schema)
          Validates the given prehtml-xml.
static boolean validateField(Node field)
          This method validates one field.
static int validateForm(Node form)
          This method can validate one form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Validator

public Validator()
Method Detail

validate

public static boolean validate(Document prehtml,
                               Document schema)
Validates the given prehtml-xml. Returns true if everything is valid, false if errors are found. Detailed information about the errors are placed as subnodes of the invalid fields.

Parameters:
prehtml - the prehtml which should be validated
schema - the wizardschema which is needed to validate at all
Returns:
True is the form is valid, false if it is invalid

validateForm

public static int validateForm(Node form)
This method can validate one form. It returns the number of invalid fields in the form.

Parameters:
form - The form to be validated.
Returns:
The number of invalid fields found.

validateField

public static boolean validateField(Node field)
This method validates one field.

Parameters:
field - the field which should be validated.
Returns:
true is the field is valid, false if it is invalid.

addValidationError

public static void addValidationError(Node validationnode,
                                      int errortype,
                                      String errormsg)
This method adds a validation error to the form.

Parameters:
validationnode - this node was validated
errortype - what kind of error was it?
errormsg - what errormessage should be placed.

createStepsOverview

public static void createStepsOverview(Document prehtml,
                                       Document schema)
Constructs an overview-node in the pre-html where all steps are described. Also, information about valid and non-valid form-schema's are placed in the steps-overview. The node looks like this:
 <steps-validator valid="false" allowsave="false" allowcancel="true">
      <step form-schema="schema-id" valid="true" />
      <step form-schema="schema-id" valid="false" />
 </steps-validator>
 
THis method creates a steps-overview which can be used by the html to show what forms are valid and what are not.

Parameters:
prehtml - the prehtml data node
schema - the original wizardschema


MMBase 2.0-SNAPSHOT - null