I tried to do something with RequiredFieldValidator, @Validations( stringLengthFields [EMAIL PROTECTED](type = ValidatorType.SIMPLE, trim = true, minLength="1" , fieldName = "empl.name", message = "required field")}, requiredFields = [EMAIL PROTECTED](type = ValidatorType.SIMPLE, fieldName = "empl.dob", message = "dob - required field")} ) public String insertEmpl() { //do something here only if both DOB and NAME are not null (or size 0) }
but it didn't work out. Jim Kiley wrote: > > Fair enough. Is this something you could solve with a validate() method > on > your action, assuming that your action is ValidationAware? > > On Tue, Jun 24, 2008 at 9:45 AM, xianwinwin <[EMAIL PROTECTED]> wrote: > >> >> But that means that ALL objects type Empl will have a mandatory field >> called >> DOB. I wish to have more flexibility by choosing the mandatory field >> based >> on the user's action. >> >> >> >> Jim Kiley wrote: >> > >> > If "empl" is a field on your action, and your JSP references the field >> as >> > "empl.date," put the validation on the setter for the date field of >> Empl, >> > rather than on the action. >> > >> > On Tue, Jun 24, 2008 at 9:06 AM, xianwinwin <[EMAIL PROTECTED]> >> wrote: >> > >> >> >> >> hi Lukasz >> >> >> >> In your example, you wrote: >> >> >> >> Private Date today; >> >> >> >> @RequiredFieldValidator(message = "Date is required") >> >> public Date getToday() { >> >> return today; >> >> } >> >> >> >> this works great also in my application, but my question is different, >> I >> >> don't have a field called today, I have an object name Empl (that has >> a >> >> field date) >> >> >> >> so I have: >> >> >> >> public Empl getEmpl() >> >> { >> >> >> >> >> >> } >> >> >> >> in my action: insertEmpl() >> >> I would like to make sure that DOB (Date Of Birth) was input by the >> user. >> >> This, I still didn't figure out how to do. >> >> >> >> The configuration that I have is this: >> >> >> >> >> >> @Validations( >> >> stringLengthFields ={ >> >> @StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim = true, >> >> minLength="1" , fieldName = "empl.name", message = "required field") >> >> >> >> } >> >> ) >> >> public String insertEmpl() >> >> { >> >> //do something here only if both DOB and NAME are not null (or >> >> size >> >> 0) >> >> >> >> } >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> Lukasz Lenart wrote: >> >> > >> >> > Hi, >> >> > >> >> >> This also works on my end *BUT* the Date in part of an Object (not >> a >> >> >> field) >> >> > >> >> > Could you show your configuration? >> >> > >> >> > >> >> > Regards >> >> > -- >> >> > Lukasz >> >> > http://www.lenart.org.pl/ >> >> > >> >> > >> --------------------------------------------------------------------- >> >> > To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> > For additional commands, e-mail: [EMAIL PROTECTED] >> >> > >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/S2%3A-validation-notation-on-DATE-%28object-that-has-a-Date-field%29-tp17995565p18090595.html >> >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> > >> > >> > -- >> > Jim Kiley >> > Technical Consultant | Summa >> > [p] 412.258.3346 [m] 412.445.1729 >> > http://www.summa-tech.com >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/S2%3A-validation-notation-on-DATE-%28object-that-has-a-Date-field%29-tp17995565p18091357.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > Jim Kiley > Technical Consultant | Summa > [p] 412.258.3346 [m] 412.445.1729 > http://www.summa-tech.com > > -- View this message in context: http://www.nabble.com/S2%3A-validation-notation-on-DATE-%28object-that-has-a-Date-field%29-tp17995565p18092117.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]