Hi
As far as i remeber It works as a chain. Struts processes validators in
depends attribute from left to right.
If a validator fails (returns false) struts doesn't process the next one.
If you are thinking of creating custom validator remember that even if your
custom validator fails it doesn't mean that your form is invalid! You must
remember to add ActionError/ActionMessage to ActionErrors/ActionMessages
passed as a parameter to yor validator.
If you are thinking of creation new validators that is to be used in depends
chain maybe you will be interested in my solution:
I created my own 2 validators : gotoNextIf, skipNextIf. Both are derived
from ValidWhen validator but gives me great flexibility in depends chain.
GotoNextIf evaluates condition and if its true it returns true and control
is passed to next validator in a chain.
SkipNext does the same job but returns false if condition is met and next
validators in a chains are skipped.
The condition i use is the same as used in validwhen test expression
(currently i modified it a little bit to support UTF-8 in string literals)
The most important: Both validators DO NOT add any entries to
ActionErrors/ActionMessages so they act only as propagation or cut point in
a chain.
You may wonder why i have created 2 validators with similiar functionality
and not utilize any ! in test condition. The problem is that antlr gramma
which is used in test condition in validwhen validator is quite weird and
non-intuitive.
I


milus
2006/6/3, Scott Van Wart <[EMAIL PROTECTED]>:

I've been looking through guides and such online, but I'm not really
clear how the validations work.  For example, the JavaDoc for
org.apache.struts.validator.FieldChecks.validateLong says it returns
"true if valid, false otherwise.", but if the checked value can be
converted to java.lang.Long, it returns the value itself, rather than
Boolean.TRUE or Boolean.FALSE.  I want to combine my own pluggable
validators with the 'validwhen' validator, but I'm not sure of the order:

- When multiple validators are listed in the 'depends' attribute, are
all validators called, or are they called in order until one returns
Boolean.TRUE or some other value?
- Must all validators return Boolean.TRUE, or some other value, or must
at least one return this value?

Thanks,
  Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to