aspose file tools*
The moose likes Struts and the fly likes form validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "form validation" Watch "form validation" New topic
Author

form validation

suresh sai
Ranch Hand

Joined: Jul 16, 2007
Posts: 62
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
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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

Joined: Jul 16, 2007
Posts: 62
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

Joined: Feb 08, 2006
Posts: 948
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: form validation