There are two validators which come with Struts: "requiredif" and
"validwhen"; "validwhen" is considered the logical successor to
"requiredif", although I have never really been comfortable using it.
One of my colleagues has submitted an enhancement request which uses
the JEXL expression evaluator to support extremely rich conditional
validation, and we're using it pretty successfully here. The one
limitation is that, because of how the <html:javascript> tag works,
sometimes you end up with invalid javascript if you use client side
validation with the JEXL validator. (Note that the JEXL validator
itself doesn't do any client-side validation.)
Anyway, there have been some concerns expressed about adding the
dependencies required by the JEXL validator directly to the Struts
core, and now that this other issue with client-side javascript has
come up, I'm not going to rush to commit the changes -- but the
patches are in Bugzilla, and anyone willing to spend an hour or less
could augment their own Struts project with the code and use the JEXL
validator.
See http://issues.apache.org/bugzilla/show_bug.cgi?id=34849 for my
colleague's solution. I just also came across
http://issues.apache.org/bugzilla/show_bug.cgi?id=22743, an older
solution from Rick Hightower which is equivalent in intent and which
also provides code for an alternative solution. The ticket for the
dynamic JS bug is
http://issues.apache.org/bugzilla/show_bug.cgi?id=35806
Hope this helps.
Joe
At 3:09 PM +0200 7/27/05, Marc Demlenne wrote:
Hi and thanks for the answer,
In fact my problem could be explained the following way :
Having two fields A and B, I need to validate A if
(A == mask) OR (A == B)
I don't know if it is possible to include a field in a mask
expression. But in the other case, I need to have an alternative
between the two validators. Is thos possible with struts validator ?
If this isn't possible, I'll need to create my own validator plugin
But if someone has eny advice, it's welcomed !
On 26/07/05, Glen Mazza <[EMAIL PROTECTED]> wrote:
I'm not exactly certain of your needs, but I think you can always
activate validation but just change the validation code based on the
value/state of other fields (such as the "original" one you mention).
Perhaps the Java code example on page 38 of
http://www.objectsource.com/Struts_Survival_Guide.pdf can be of help for
you--I am unsure.
Glen
Marc Demlenne wrote:
> Hi,
>
> I need to use a text box that must correspond to a regular expression,
> so it can be validated by the "mask" validator.
>
> However, if and only if this value remains unchanged by customer, it
> has not to be validated and can stay as is, even if it doesn't
> correspond to the mask. This could be easily done by checking the
> value against another field containing the original one with
> "validwhen" validator for instance.
>
> However, I need to have my field validated even if only one of those
> validators are OK, not both ones.
>
> How can I make this using validator plugin ?
>
> Thanks very much for any answer.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Marc Demlenne
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]