tarek.nabil wrote:

Hi Erik,

Actually after some reasoning about the application I came to a
conclusion that I will not use the integration between Struts and the
Validator framework. I might still use the ready made validators, but I
will call them explicitly.



Yeah don't forget that you can still use the Validator plugin on the server side, even if you don't use the Validator brand of ActionForms. See Rick Reumann's site for examples of this (if I'm not mistaken; I know he uses this technique).


The reason is, the pages in the application are designed to do search,
add, edit and delete functionalities in the same page. We do this using
the same form, and the button the user presses is what determines the
operation. This makes all the validations kind of conditional. For
example, the id will be mandatory if you're deleting but the name will
be mandatory if you're adding and so on. As a result, to support this, I
will have to declare all my required validations using requiredif since
usually most validations depend on required.



Well, there is an easy way to conquer this problem -- you just use multiple action mappings for the same Action that use the same ActionForm. All you need is a different URL then. Each action mapping has a different name (an alias to the same ActionForm) -- triggering a different section of your validation.xml file to be used for validation. This way you can validate only the fields required for the given use case, and yet you have a single Action and a single ActionForm, and even a single form JSP. Have you considered this?


Since requiredif does not have a clientside script part, that means I
will only benefit from server side validation, that's problem number
one.



But client side validation is only a luxury for the user while server side validation is mandatory, so I don't understand your statement here.


Problem number two is that declaring all required validations as
requiredif will be very time consuming, since the syntax for requiredif
is a bit awkward and very verbose. Adding the fact that requiredif is
not supported in the version I'm using makes the integration almost
meaningless. As you see, no clientside, time consuming simple
validations and above all, it's not currently working. That led me to
the decision to just write my own validation code in the validate
method.



I'm really confused about what you are trying to do here. requiredif is for a case where, for example, you have a drop down box paired with a text field. You only want the text field value to be validated if the drop down box value is equal to "foo". Are you trying to use it to accomplish something else? (Like what I describe in my second paragraph?)


The only thing that would make me change my mind is if I were able to
use validwhen with 1.1b2. Only then will this make sense, although even
in this case I would still have to write my own clientside validations.
Or wouldn't I? Depends on whether validwhen generates javascript for
clientside validation. Does it do that? And do you think this is
possible?



I won't comment on the client side validation, because I don't use it. The only client side validation I tend to use (if at all) is a blank field check when the form happens to be very large, unless of course my customer wants something else. If the customer wants something else, I give him a desktop application. :)


I also don't know about retrofitting validwhen for 1.1, but again, the idea arises that perhaps you could embed validwhen (or something just like it) as a custom validator? Does the version of Struts you are using support custom validators?

Hope that helps,

Erik

Thanks

-----Original Message-----
From: Erik Weber [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 19, 2005 7:54 PM
To: Struts Users Mailing List
Subject: Re: requiredif


Oh, I'm sorry. I pulled that from the last release of 1.1. Zoinks, you
are stuck with a pre-1.1 version? Perhaps you could write a custom
validator plugin that basically does the same thing?

tarek.nabil wrote:



Hi Erik,

I tried it and it didn't work. I checked out the validator and struts jar files and it turned out that the org.apache.struts.validator.FieldChecks class does not exist in either of them. Is it possible that it was introduced after 1.1b2? I'm sure it's in RC1 because I'm using the documentation shipped in 1.1RC1.

Thanks again for your help.

-----Original Message-----
From: tarek.nabil
Sent: Tuesday, April 19, 2005 7:41 PM
To: Struts Users Mailing List
Subject: RE: requiredif

Thanks Erik.

I was wondering, is there a client side JavaScript part?

Also, is it possible to use validwhen with the old versions of struts (1.1b2).

Thanks for your help.

-----Original Message-----
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 19, 2005 3:24 PM
To: Struts Users Mailing List
Subject: Re: requiredif


<!-- requiredif --> <validator name="requiredif" classname="org.apache.struts.validator.FieldChecks" method="validateRequiredIf" methodParams="java.lang.Object,

org.apache.commons.validator.ValidatorAction,
                           org.apache.commons.validator.Field,
                           org.apache.struts.action.ActionErrors,
                           org.apache.commons.validator.Validator,
                           javax.servlet.http.HttpServletRequest"
                      msg="errors.required"/>


Erik


tarek.nabil wrote:





Hi,

I'm stuck with Struts 1.1b2 and I need to do some conditional validation. AFAIK, the way to do this for this version is using the requiredif validator. The problem is, I cannot find any reference information on how to add this validator to the validator-rules.xml configuration file.

Please advise on how to do this and if there's a better way to do this





with this old version. For example, is it possible to configure the old








Struts/Validator versions to use validwhen?

Any help is appreciated.

Tarek Nabil


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








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







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





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



Reply via email to