Re: Struts Validator Framework: client-side validation problem
I'm not familiar with the tag; does that auto-include the script defining the validateForm() function? If not, I'd suggest a missing
Re: Struts Validator Framework: client-side validation problem
What happens? What do you expect to happen? What's your validation config? We need something beyond "it doesn't work". Dave On Sep 2, 2011 3:47 AM, "RajasekharReddy" wrote: > I am trying to implement Client-Side Validations using struts 1.3 > > But server Side validations are working properly, but Client-Side > Validations are not working properly. > > My code is as follows > > > > > <%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %> > <%@ taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %> > > > > > LoginPage > > > > > > > > > > > > > > > > > > > > Click here to href="SignUp.jsp">SignUp > > > > > > > -- > View this message in context: http://struts.1045723.n5.nabble.com/Struts-Validator-Framework-client-side-validation-problem-with-submitting-buttons-tp3481073p4761399.html > Sent from the Struts - User mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: Struts Validator Framework: problem with Custom Validator
No-reply? :( However, I solved. Now all works well. ** SERVER-SIDE ** To avoid the deprecated method Resources.getActionMessage(HttpServletRequest request, ValidatorAction va, Field field) I used Resources.getActionMessage(Validator v, HttpServletRequest request, ValidatorAction va, Field field) in my custom validator java class. I added "org.apache.commons.validator.Validator" to methodParams of the "twofields" custom validator in validator-rules.xml. ** CLIENT-SIDE ** I changed oTwoFields = new twofields(); with eval('oTwoFields = new ' + form.name + '_twofields();'); That's all. cacodemon79 wrote: > > I'm using Struts 1.3. > I'm trying to write a custom validator to check that 2 fields are > identical. > > 1) I modified my validator-rules.xml by adding my own validator (called > "uguale"): > ** > validator-rules.xml > ** > > classname="it.sfidiamoci.validator.ValidatorPersonalizzati" > method="validateUguale" > > methodParams="java.lang.Object,org.apache.commons.validator.ValidatorAction,org.apache.commons.validator.Field,org.apache.struts.action.ActionErrors,javax.servlet.http.HttpServletRequest" > > depends="required" > msg="errors.uguale"> > > > > > > 2) I modified my validation.xml by adding the new validator (called > "uguale"): > ** > validator-rules.xml > ** > > >key="${var:minlength}" > resource="false" /> > >/> > > minlength > 8 > > > mask > ^[a-zA-Z0-9_.]*$ > > > secondProperty > password2 > > > > 3) I added the key "errors.password.uguale" in > ApplicationResources.properties > *** > ApplicationResources.properties > *** > errors.password.uguale=Le password inserite non sono uguali > > 4) I created the class "ValidatorPersonalizzati" to handle the custom > validator "validateUguale": > > ValidatorPersonalizzati.java > > package it.sfidiamoci.validator; > > import javax.servlet.http.HttpServletRequest; > > import org.apache.commons.validator.Field; > import org.apache.commons.validator.GenericValidator; > import org.apache.commons.validator.ValidatorAction; > import org.apache.commons.validator.util.ValidatorUtils; > import org.apache.struts.action.ActionErrors; > import org.apache.struts.validator.Resources; > > > public class ValidatorPersonalizzati{ > > public static boolean validateUguale(Object bean, ValidatorAction > va,Field field, ActionErrors errors,HttpServletRequest request){ > > String value = > ValidatorUtils.getValueAsString(bean,field.getProperty()); > System.out.println("value="+value); > String sProperty2 = field.getVarValue("secondProperty"); > String value2 = > ValidatorUtils.getValueAsString(bean,sProperty2); > System.out.println("value2="+value2); > if (!GenericValidator.isBlankOrNull(value)){ > try{ > if (!value.equals(value2)){ > > errors.add(field.getKey(),Resources.getActionMessage(request, va, > field)); > return false; > } > } > catch (Exception e){ > > errors.add(field.getKey(),Resources.getActionMessage(request, va, > field)); > return false; > } > } > > return true; > > } > } > > 5) I have two fields ("password", "password2") to check in my jsp: > ** > test.jsp > ** > >class="col1"> key='registrazioneUtente.password.label'/> >property="password" styleId="password" > maxlength="<%= passwordMaxLength %>" /> >key='registrazioneUtente.password2.label'/> >property="password2" styleId="password2" > maxlength="<%= passwordMaxLength %>" /> > > > > When I submit the form in my jsp, standard validations (e.g
Re: Struts Validator Framework: problem with Custom Validator
Now, server-side validation works! I changed ActionErrors class with ActionMessages class into my java validation method and into "validator-rules.xml". The only problem is that Resources.getActionMessage(request, va, field) method in my custom validator class is deprecated and I don't know how to replace it. Can you give me any suggestions? On the client-side, I have the same problem. I see a javascript warning in browser: "twofields is not defined". I have also tried to perform some changes to my files: ** validator-rules.xml ** http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd";> ... ... ... ** validation.xml ** http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd";> ... ... ... minlength 8 mask ^[a-zA-Z0-9_.]*$ secondProperty password2 So, my custom validation ("twofields") doesn't still work on client-side. Can you help me? I also tried to change the version of dtd validator...but nothing changed. I can't understand where is the problem. cacodemon79 wrote: > > I'm using Struts 1.3. > I'm trying to write a custom validator to check that 2 fields are > identical. > > 1) I modified my validator-rules.xml by adding my own validator (called > "uguale"): > ** > validator-rules.xml > ** > > classname="it.sfidiamoci.validator.ValidatorPersonalizzati" > method="validateUguale" > > methodParams="java.lang.Object,org.apache.commons.validator.ValidatorAction,org.apache.commons.validator.Field,org.apache.struts.action.ActionErrors,javax.servlet.http.HttpServletRequest" > > depends="required" > msg="errors.uguale"> > > > > > > 2) I modified my validation.xml by adding the new validator (called > "uguale"): > ** > validator-rules.xml > ** > > >key="${var:minlength}" > resource="false" /> > >/> > > minlength > 8 > > > mask > ^[a-zA-Z0-9_.]*$ > > > secondProperty > password2 > > > > 3) I added the key "errors.password.uguale" in > ApplicationResources.properties > *** > ApplicationResources.properties > *** > errors.password.uguale=Le password inserite non sono uguali > > 4) I created the class "ValidatorPersonalizzati" to handle the custom > validator "validateUguale": > > ValidatorPersonalizzati.java > > package it.sfidiamoci.validator; > > import javax.servlet.http.HttpServletRequest; > > import org.apache.commons.validator.Field; > import org.apache.commons.validator.GenericValidator; > import org.apache.commons.validator.ValidatorAction; > import org.apache.commons.validator.util.ValidatorUtils; > import org.apache.struts.action.ActionErrors; > import org.apache.struts.validator.Resources; > > > public class ValidatorPersonalizzati{ > > public static boolean validateUguale(Object bean, ValidatorAction > va,Field field, ActionErrors errors,HttpServletRequest request){ > > String value = > ValidatorUtils.getValueAsString(bean,field.getProperty()); > System.out.println("value="+value); > String sProperty2 = field.getVarValue("secondProperty"); > String value2 = > ValidatorUtils.getValueAsString(bean,sProperty2); > System.out.println("value2="+value2); > if (!GenericValidator.isBlankOrNull(value)){ > try{ > if (!value.equals(value2)){ > > errors.add(field.getKey(),Resources.getActionMessage(request, va, > field)); > return false; > } > } > catch (Exception e)
Re: Struts Validator Framework: client-side validation problem with submitting buttons
Thank you very much. Laurie Harper wrote: > > I did what I should have done in the first place and looked it up: > Form.submit() is specified to *not* call the onsubmit handler, so this > is the correct behaviour (and should be consistent across all browsers). > > When in doubt, check the documentation :-) > > L. > > cacodemon79 wrote: >> Bingo! >> Now it works! >> Thanks a lot. >> However i can't understand why the onsubmit handler is not triggered by >> the >> submit() function! >> >> >> Laurie Harper wrote: >>> Did you confirm whether calling the form's submit() method triggers its >>> onsubmit handler? It may be that calling submit() bypasses it, in which >>> case an explicit guard in your submit function might do the trick: >>> >>> function submitRegistrazioneUtenteForm(nomeForm){ >>>var form = ...; >>>if (validateRegistrazioneUtenteForm(form)) { >>> form.submit(); >>>} >>>return false; >>> } >>> >>> L. >>> >>> cacodemon79 wrote: No suggestions? :( I also tried to use document.registrazioneUtenteForm.submit()") instead of eval("document."+nomeForm+".submit()") but the result is the same. The form is submitted but I can't see any javascript alerts. I can't understand where is the problem. I hope you can help me. Thanks. cacodemon79 wrote: > Hi, I'm using Struts Validator Framework (Struts 1.3). > Server-side validation works well. > The problem is in client-side validation. > > The form name I have to validate is: RegistrazioneUtenteForm. > > In my jsp page I have 2 buttons: > 1) href="javascript:submitRegistrazioneUtenteForm('registrazioneUtenteForm')"> key='form.submit'/> > 2) > and the following form declaration: > focus="username" > onsubmit="return validateRegistrazioneUtenteForm(this)"> > Moreover I have enabled javascript validation: > > > The javascript function submitRegistrazioneUtenteForm is the > following: > function submitRegistrazioneUtenteForm(nomeForm){ > eval("document."+nomeForm+".submit()"); > } > > If I click on the second button (html:submit), all works well (I get > javascript alerts). > If I click on the first button (html:link), the form is submitted but > I > can't see any javascript alerts. > > I can't understand where is the problem. > > Can you help me? > > Thanks in advance. > >>> >>> - >>> 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] > > > -- View this message in context: http://www.nabble.com/Struts-Validator-Framework%3A-client-side-validation-problem-with-submitting-buttons-tp18042962p18093853.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]
Re: Struts Validator Framework: client-side validation problem with submitting buttons
I did what I should have done in the first place and looked it up: Form.submit() is specified to *not* call the onsubmit handler, so this is the correct behaviour (and should be consistent across all browsers). When in doubt, check the documentation :-) L. cacodemon79 wrote: Bingo! Now it works! Thanks a lot. However i can't understand why the onsubmit handler is not triggered by the submit() function! Laurie Harper wrote: Did you confirm whether calling the form's submit() method triggers its onsubmit handler? It may be that calling submit() bypasses it, in which case an explicit guard in your submit function might do the trick: function submitRegistrazioneUtenteForm(nomeForm){ var form = ...; if (validateRegistrazioneUtenteForm(form)) { form.submit(); } return false; } L. cacodemon79 wrote: No suggestions? :( I also tried to use document.registrazioneUtenteForm.submit()") instead of eval("document."+nomeForm+".submit()") but the result is the same. The form is submitted but I can't see any javascript alerts. I can't understand where is the problem. I hope you can help me. Thanks. cacodemon79 wrote: Hi, I'm using Struts Validator Framework (Struts 1.3). Server-side validation works well. The problem is in client-side validation. The form name I have to validate is: RegistrazioneUtenteForm. In my jsp page I have 2 buttons: 1) 2) and the following form declaration: Moreover I have enabled javascript validation: The javascript function submitRegistrazioneUtenteForm is the following: function submitRegistrazioneUtenteForm(nomeForm){ eval("document."+nomeForm+".submit()"); } If I click on the second button (html:submit), all works well (I get javascript alerts). If I click on the first button (html:link), the form is submitted but I can't see any javascript alerts. I can't understand where is the problem. Can you help me? Thanks in advance. - 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]
Re: Struts Validator Framework: client-side validation problem with submitting buttons
Hi, 2008/6/23 cacodemon79 <[EMAIL PROTECTED]>: > > Bingo! > Now it works! > Thanks a lot. > However i can't understand why the onsubmit handler is not triggered by the > submit() function! > Maybe it depends on Web Browser, did you try with others? Regards -- Lukasz http://www.lenart.org.pl/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Validator Framework: client-side validation problem with submitting buttons
Bingo! Now it works! Thanks a lot. However i can't understand why the onsubmit handler is not triggered by the submit() function! Laurie Harper wrote: > > Did you confirm whether calling the form's submit() method triggers its > onsubmit handler? It may be that calling submit() bypasses it, in which > case an explicit guard in your submit function might do the trick: > > function submitRegistrazioneUtenteForm(nomeForm){ >var form = ...; >if (validateRegistrazioneUtenteForm(form)) { > form.submit(); >} >return false; > } > > L. > > cacodemon79 wrote: >> No suggestions? :( >> >> I also tried to use >> document.registrazioneUtenteForm.submit()") >> instead of >> eval("document."+nomeForm+".submit()") >> but the result is the same. The form is submitted but I can't see any >> javascript alerts. >> >> I can't understand where is the problem. >> >> I hope you can help me. >> >> Thanks. >> >> >> >> cacodemon79 wrote: >>> Hi, I'm using Struts Validator Framework (Struts 1.3). >>> Server-side validation works well. >>> The problem is in client-side validation. >>> >>> The form name I have to validate is: RegistrazioneUtenteForm. >>> >>> In my jsp page I have 2 buttons: >>> 1) >> href="javascript:submitRegistrazioneUtenteForm('registrazioneUtenteForm')">>> key='form.submit'/> >>> 2) >>> and the following form declaration: >>> >> onsubmit="return validateRegistrazioneUtenteForm(this)"> >>> Moreover I have enabled javascript validation: >>> >>> >>> The javascript function submitRegistrazioneUtenteForm is the following: >>> function submitRegistrazioneUtenteForm(nomeForm){ >>> eval("document."+nomeForm+".submit()"); >>> } >>> >>> If I click on the second button (html:submit), all works well (I get >>> javascript alerts). >>> If I click on the first button (html:link), the form is submitted but I >>> can't see any javascript alerts. >>> >>> I can't understand where is the problem. >>> >>> Can you help me? >>> >>> Thanks in advance. >>> >> > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Struts-Validator-Framework%3A-client-side-validation-problem-with-submitting-buttons-tp18042962p18075348.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]
Re: Struts Validator Framework: client-side validation problem with submitting buttons
Did you confirm whether calling the form's submit() method triggers its onsubmit handler? It may be that calling submit() bypasses it, in which case an explicit guard in your submit function might do the trick: function submitRegistrazioneUtenteForm(nomeForm){ var form = ...; if (validateRegistrazioneUtenteForm(form)) { form.submit(); } return false; } L. cacodemon79 wrote: No suggestions? :( I also tried to use document.registrazioneUtenteForm.submit()") instead of eval("document."+nomeForm+".submit()") but the result is the same. The form is submitted but I can't see any javascript alerts. I can't understand where is the problem. I hope you can help me. Thanks. cacodemon79 wrote: Hi, I'm using Struts Validator Framework (Struts 1.3). Server-side validation works well. The problem is in client-side validation. The form name I have to validate is: RegistrazioneUtenteForm. In my jsp page I have 2 buttons: 1) 2) and the following form declaration: Moreover I have enabled javascript validation: The javascript function submitRegistrazioneUtenteForm is the following: function submitRegistrazioneUtenteForm(nomeForm){ eval("document."+nomeForm+".submit()"); } If I click on the second button (html:submit), all works well (I get javascript alerts). If I click on the first button (html:link), the form is submitted but I can't see any javascript alerts. I can't understand where is the problem. Can you help me? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Validator Framework: client-side validation problem with submitting buttons
Hi, Maybe you should install Firebug for Firefox (not working with 3.0) and debug the JavaScript? Regards -- Lukasz http://www.lenart.org.pl/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Validator Framework: client-side validation problem with submitting buttons
No suggestions? :( I also tried to use document.registrazioneUtenteForm.submit()") instead of eval("document."+nomeForm+".submit()") but the result is the same. The form is submitted but I can't see any javascript alerts. I can't understand where is the problem. I hope you can help me. Thanks. cacodemon79 wrote: > > Hi, I'm using Struts Validator Framework (Struts 1.3). > Server-side validation works well. > The problem is in client-side validation. > > The form name I have to validate is: RegistrazioneUtenteForm. > > In my jsp page I have 2 buttons: > 1) href="javascript:submitRegistrazioneUtenteForm('registrazioneUtenteForm')"> key='form.submit'/> > 2) > and the following form declaration: > onsubmit="return validateRegistrazioneUtenteForm(this)"> > Moreover I have enabled javascript validation: > > > The javascript function submitRegistrazioneUtenteForm is the following: > function submitRegistrazioneUtenteForm(nomeForm){ > eval("document."+nomeForm+".submit()"); > } > > If I click on the second button (html:submit), all works well (I get > javascript alerts). > If I click on the first button (html:link), the form is submitted but I > can't see any javascript alerts. > > I can't understand where is the problem. > > Can you help me? > > Thanks in advance. > -- View this message in context: http://www.nabble.com/Struts-Validator-Framework%3A-client-side-validation-problem-with-submitting-buttons-tp18042962p18072574.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]
RE: Struts validator framework
You define the field label using an argument, i.e. So the validator is using the field's label to fill in the message. The default message for errors.required is: errors.required={0} is required. So, it will replace {0} with the prompt.username entry that also appears as a resource. To display the error next to the field, you could place an next to the field. IF you do this though, realize that Struts is going to place the errors.header, errors.footer, errors.prefix and errors.suffix around the items. If you use the defaults that would not look right next to a field - fine for the top of the page, but not for a field. You'll have to change them. Otherwise, you could use an tag specific for that field and then format the html yourself as it iterates one (or possibly several) error messages for each field. Good luck, Eric -Original Message- From: Zhang, Larry (L.) [mailto:[EMAIL PROTECTED] Sent: Thu 5/15/2008 6:14 PM To: Struts Users Mailing List Cc: Subject: Struts validator framework Say if I have two text fields, one label is Please enter name:, and the other label is Please enter SSN:. In struts validator framework, if I need to validate these two fields using required validator, is there any way to relate the field label to the message? Or does struts validator support displaying the validation message right next to the field (so that the user easily know which fields are invalid)? Thank you very much. - 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]
RE: Struts Validator Framework
Hi, I'm reposting this mail with the hope that I can get response from someone. If anyone of you have any clue on the question mentioned below, kindly get back. Thanks, Ashutosh -Original Message- From: Ashutosh Satyam Sent: Thursday, August 25, 2005 11:28 PM To: Struts Users Mailing List Subject: RE: Struts Validator Framework Hi Hubert, Thanks for your response. It worked the way you told by using dot delimiters to point out the nested object. On the same lines, I have one more question. How do I validate an array of objects. This is my class strucutre. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Class X{ String a; Y b; } Class Y{ String i; String[] j; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - I could reference the nested element 'i' in class Y by using "b.i", but I couldn't validate j; I tried the following with the indexedListProperty construct: ---failed ---failed ---failed but each time I got an exception: java.lang.NullPointerException at org.apache.commons.validator.Field.getIndexedProperty(Field.java:780) at org.apache.commons.validator.Field.validate(Field.java:875) at org.apache.commons.validator.Form.validate(Form.java:174) at org.apache.commons.validator.Validator.validate(Validator.java:367) Could you tell me where am I doing wrong. Regards, Ashutosh -Original Message- From: Hubert Rabago [mailto:[EMAIL PROTECTED] Sent: Thu 8/25/2005 1:36 AM To: Struts Users Mailing List Cc: Subject: Re: Struts Validator Framework I've never used Validator outside of Struts, but I do know I've successfully referenced nested elements while validating, by using dot notation. In your case, you can refer to fields "a", "b", "obj.i, "obj.j", "obj.obj.k". Hubert On 8/24/05, Ashutosh Satyam <[EMAIL PROTECTED]> wrote: > Hi, > I am using the Struts Validator(Commons Validator) outside the Struts framework, to do validation. > I would like to know how to validate an object when it has objects nested within it, and I need to > validate the fields in those nested objects, too. > > Precisely I intend to achieve the following. A pseudo code of my requirement. > I am passing object of class X to the validator., as shown below > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > Class X{ > String a; > String b; > Y obj; > } > Class Y{ > String i; > String j; > Z obj; > } > Class Z{ > String k; > } > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > I am trying to validate an object of class X, and I need to validate the enclosed object of Class Y, > and the object of class Z further encapsulated in Y. > > Is it doable using the existing Validator framework. Is there a way to specify this kind of > nested validation in the "validation-rules.xml" ( configuration file used by validator ) > > If yes can anyone give me a pointer on the same. > > > Regards, > Ashutosh > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Struts Validator Framework
Hi Hubert, Thanks for your response. It worked the way you told by using dot delimiters to point out the nested object. On the same lines, I have one more question. How do I validate an array of objects. This is my class strucutre. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Class X{ String a; Y b; } Class Y{ String i; String[] j; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - I could reference the nested element 'i' in class Y by using "b.i", but I couldn't validate j; I tried the following with the indexedListProperty construct: ---failed ---failed ---failed but each time I got an exception: java.lang.NullPointerException at org.apache.commons.validator.Field.getIndexedProperty(Field.java:780) at org.apache.commons.validator.Field.validate(Field.java:875) at org.apache.commons.validator.Form.validate(Form.java:174) at org.apache.commons.validator.Validator.validate(Validator.java:367) Could you tell me where am I doing wrong. Regards, Ashutosh -Original Message- From: Hubert Rabago [mailto:[EMAIL PROTECTED] Sent: Thu 8/25/2005 1:36 AM To: Struts Users Mailing List Cc: Subject: Re: Struts Validator Framework I've never used Validator outside of Struts, but I do know I've successfully referenced nested elements while validating, by using dot notation. In your case, you can refer to fields "a", "b", "obj.i, "obj.j", "obj.obj.k". Hubert On 8/24/05, Ashutosh Satyam <[EMAIL PROTECTED]> wrote: > Hi, > I am using the Struts Validator(Commons Validator) outside the Struts framework, to do validation. > I would like to know how to validate an object when it has objects nested within it, and I need to > validate the fields in those nested objects, too. > > Precisely I intend to achieve the following. A pseudo code of my requirement. > I am passing object of class X to the validator., as shown below > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > Class X{ > String a; > String b; > Y obj; > } > Class Y{ > String i; > String j; > Z obj; > } > Class Z{ > String k; > } > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > I am trying to validate an object of class X, and I need to validate the enclosed object of Class Y, > and the object of class Z further encapsulated in Y. > > Is it doable using the existing Validator framework. Is there a way to specify this kind of > nested validation in the "validation-rules.xml" ( configuration file used by validator ) > > If yes can anyone give me a pointer on the same. > > > Regards, > Ashutosh > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts Validator Framework
I've never used Validator outside of Struts, but I do know I've successfully referenced nested elements while validating, by using dot notation. In your case, you can refer to fields "a", "b", "obj.i, "obj.j", "obj.obj.k". Hubert On 8/24/05, Ashutosh Satyam <[EMAIL PROTECTED]> wrote: > Hi, > I am using the Struts Validator(Commons Validator) outside the Struts > framework, to do validation. > I would like to know how to validate an object when it has objects nested > within it, and I need to > validate the fields in those nested objects, too. > > Precisely I intend to achieve the following. A pseudo code of my requirement. > I am passing object of class X to the validator., as shown below > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > Class X{ > String a; > String b; > Y obj; > } > Class Y{ > String i; > String j; > Z obj; > } > Class Z{ > String k; > } > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > I am trying to validate an object of class X, and I need to validate the > enclosed object of Class Y, > and the object of class Z further encapsulated in Y. > > Is it doable using the existing Validator framework. Is there a way to > specify this kind of > nested validation in the "validation-rules.xml" ( configuration file used by > validator ) > > If yes can anyone give me a pointer on the same. > > > Regards, > Ashutosh > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]