• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

form validation

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All., I am doing form validation using struts validator frame work.How can I do validation for my form which in turns contains an object of another class.Here I am showing mycode in short.


public class Student{
String name; //its getters & setters

}

myform.java
---------------

public class MyClass extends ValidatorForm{
Student student //its getters & setters
}
myjsp.jsp
----------
<html:text property="student.name">

here student is the object in my form(with getters and setters) and name is the property of student.

I have given every thing fine.But I dont know how to specify the field name in <formset>.I have given like this but its not working...
<formset>
<form .....>
<field property="student.name">
........
</field>
</form>
</formset>

please help mee....I have given validat=true,input......each & everything
Thanks in advance
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, using a property value like "student.name" is how you do it. Make sure you have methods named getStudent() and getName() with the correct case. When you say "not working" what do you mean? What validation rule are you using? In your file do you have a "depends" attribute as part of your field tag?

- Brent
 
suresh sai
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes Brent.,Thanks for your response.I am sorry to say ,I have forgotten to give some information.After hitting the submit button ,before going to the action class the validations are performed. After completion of the validations ,then only the action class method(or execute()) is called.I think I am right.But for my page after hitting the submit button it directly goes to the action class method(or execute()) and the page is forwarded to me.I dont know what happens inside it.And one more thing is I am usig two struts config files and one main config file.I have setup the plug-in in main config file.I am showing plug-in here...

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/org/apache/struts/validator/validator-rules.xml, /WEB-INF/config/myvalid-validation.xml,/WEB-INF/config/myfriendvalid-validation.xml"/>
</plug-in>
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you got validation working for other pages and/or fields? Is it just this one field that has issues? Please post your exact validation rule.

- Brent
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic