Create A Size
This component does three kinds of validation:- The entered name must be non-nil and must not be an empty string.
- The entered volume must be a number (formatter validation; because the WOTextField's numberformat association is bound to a format string of "###". Alternatively, one could create an instance of NSNumberFormatter and bind it to the formatter association).
- The entered volume must be greater than 0. This validation is accomplished through the EO Key/Value validation API. See Size+BusinessLogic.m in the project source.
In all cases, the validation will cause an EOValidation exception to be raised during association evaluation. When this occurs, the methodvalidationFailedWithExceptionvalue:keyPath: is invoked. The implementation can be found in the ErrorValueComponent class implemented within the project. It is compiled only to make it possible to set a breakpoint on this method. Both the SizeCreator and the ThingCreator components use ErrorValueComponent as their superclass.
It is common (and suggested on the OmniGroup mailing list) to see implementations of methodvalidationFailedWithExceptionvalue:keyPath: that create an appropriate error message, then invoke:
- [self takveValue: aValue forKeyPath: aKeyPath]
The purpose behind the code is to push the user's entered value into some convenient location such that the form values for anything that was in error is not lost when the response is sent back to the user (the default implementation effectively causes the erroneous input to not be passed through the association). However, the above code is actually quite a nasty bug; it effectively forces the association to take the value that was thrown out as being invalid in the first place!!
The ErrorValueComponent is a subclass of WOComponent that presents a relatively generalized mechanism for storing invalid values in a convenient location such that subsequent response generation will include the erroneous input (such that the user can correct it), but will not cause the erroneous input to ever be pushed across the association once the input fails validation.
Name:
Volume:
Main
Current Sizes:
( units)