Project Wonder 5.0

er.directtoweb.delegates
Class ERDQueryValidationDelegate

java.lang.Object
  extended by er.directtoweb.delegates.ERDQueryValidationDelegate
Direct Known Subclasses:
ERDQueryValidationDelegate.DefaultQueryValidationDelegate

public abstract class ERDQueryValidationDelegate
extends java.lang.Object

A delegate class for validating user inputs before a query is executed. Validation rules are derived from the D2W context.

To disallow a query with no user inputs, create a rule like:

entity.name = 'Foo' => allowsEmptyQueryValue = "false" (BooleanAssignment)

To define a validation for a propertyKey, create a rule like:

entity.name = 'Foo' and propertyKey = 'bar' => allowsEmptyQueryValue = "false" (BooleanAssignment)

To define a minimum length validation for a (String) propertyKey, create a rule like:

entity.name = 'Foo' and propertyKey = 'bar' => minimumInputLength = "3" (Assignment)

Subclasses wishing to implement custom validation logic should implement the validateQueryValues(er.directtoweb.pages.ERD2WQueryPage) method. The implementation should catch validation exceptions and invoke ERD2WPage.validationFailedWithException(Throwable, Object, String) with any caught exceptions. To customize behavior, while retaining the default checks, extend ERDQueryValidationDelegate.DefaultQueryValidationDelegate to perform custom validations and then call validateQueryValues(er.directtoweb.pages.ERD2WQueryPage) on the superclass.

Author:
Travis Cripps
D2W Keys
displayPropertyKeysdisplayPropertyKeys
           
maximumInputLengthmaximumInputLength
           
minimumInputLengthminimumInputLength
           
maximumInputValuemaximumInputValue
           
minimumInputValueminimumInputValue
           

Nested Class Summary
static class ERDQueryValidationDelegate.DefaultQueryValidationDelegate
          A "default" implementation of a query validation delegate, which simply validates each key in the query page's display group against validation definitions from the D2W rules.
static interface ERDQueryValidationDelegate.ErrorKeys
           
static interface ERDQueryValidationDelegate.ValidationKeys
           
 
Field Summary
protected  com.webobjects.directtoweb.D2WContext d2wContext
           
 
Constructor Summary
ERDQueryValidationDelegate()
           
 
Method Summary
 com.webobjects.directtoweb.D2WContext d2wContext()
          Gets the D2WContext against which the validation definitions will be evaluated.
 boolean hasValidationDefinitionForKey(java.lang.String key)
          Determines if the D2W context contains a validation definition for the provided validation key.
protected  java.lang.String propertyKeyFromDisplayGroupKey(java.lang.String key)
          Gets the D2W property key corresponding to the display group key by matching the key with one in the D2W context's displayPropertyKeys.
 void validateNumericValueForKey(java.lang.Number value, java.lang.String key)
          Validates a string value, checking minimumInputValue and maximumInputValue.
 void validateQuery(ERD2WQueryPage sender)
          Validates the query inputs before executing the query.
abstract  void validateQueryValues(ERD2WQueryPage sender)
          Validates the query input values from the query page's display group.
 void validateStringValueForKey(java.lang.String value, java.lang.String key)
          Validates a string value, checking minimumInputLength and maximumInputLength.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

d2wContext

protected com.webobjects.directtoweb.D2WContext d2wContext
Constructor Detail

ERDQueryValidationDelegate

public ERDQueryValidationDelegate()
Method Detail

validateQuery

public void validateQuery(ERD2WQueryPage sender)
Validates the query inputs before executing the query.

Parameters:
sender - query page whose inputs to validate

validateQueryValues

public abstract void validateQueryValues(ERD2WQueryPage sender)
Validates the query input values from the query page's display group.

Parameters:
sender - query page whose inputs to validate

d2wContext

public com.webobjects.directtoweb.D2WContext d2wContext()
Gets the D2WContext against which the validation definitions will be evaluated. from

Returns:
the D2WContext

propertyKeyFromDisplayGroupKey

protected java.lang.String propertyKeyFromDisplayGroupKey(java.lang.String key)
Gets the D2W property key corresponding to the display group key by matching the key with one in the D2W context's displayPropertyKeys.

Parameters:
key - from the display group
Returns:
the corresponding D2W key, or the original key if not found

hasValidationDefinitionForKey

public boolean hasValidationDefinitionForKey(java.lang.String key)
Determines if the D2W context contains a validation definition for the provided validation key.

Parameters:
key - to check
Returns:
true if a validation definition for the given key exists

validateStringValueForKey

public void validateStringValueForKey(java.lang.String value,
                                      java.lang.String key)
                               throws com.webobjects.foundation.NSValidation.ValidationException
Validates a string value, checking minimumInputLength and maximumInputLength.

Parameters:
value - to validate
key - of the property to validate
Throws:
NSValidation.ValidationException - when the validation fails

validateNumericValueForKey

public void validateNumericValueForKey(java.lang.Number value,
                                       java.lang.String key)
                                throws com.webobjects.foundation.NSValidation.ValidationException
Validates a string value, checking minimumInputValue and maximumInputValue.

Parameters:
value - to validate
key - of the property to validate
Throws:
NSValidation.ValidationException - when the validation fails

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.