| Author |
Valdation through action class in struts 1.2
|
Ayan Biswas
Ranch Hand
Joined: Jul 10, 2010
Posts: 95
|
|
In my application I am using a single form bean for all the forms.Now,to validate a particular form field I have written individual validate() methods in the action classes .but the problem that I am facing is that I dont see any error message in the jsp pages when a validation error occurs.
Here is one of my validation methods:
and here is my jsp page
|
AyanBiswas
|
 |
Sumit Patil
Ranch Hand
Joined: May 25, 2009
Posts: 296
|
|
Ayan Biswas wrote:I have written individual validate() methods in the action classes .but the problem that I am facing is that I dont see any error message in the jsp pages when a validation error occurs.
The validate method is supposed to be inside the ActionForm class that you create.
Here is one of my validation methods:
That is not the correct implementation of validation method. It should be something like this
Please try and let us know.
|
Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
|
 |
Ayan Biswas
Ranch Hand
Joined: Jul 10, 2010
Posts: 95
|
|
Sumit Patil wrote:
The validate method is supposed to be inside the ActionForm class that you create.
Yes,I know that but the problem is that I have a single form bean for the entire application.So,if I write a validate method in the ActionForm class I would be validating all the form fields (i.e all the fields in all the forms of the entire application) each time I navigate to a particular page containing a particular form.
|
 |
Sumit Patil
Ranch Hand
Joined: May 25, 2009
Posts: 296
|
|
|
In that case, i would suggest to handle the validation inside the Action class itself. I would suggest you to use the validation framework built into struts.
|
 |
Ayan Biswas
Ranch Hand
Joined: Jul 10, 2010
Posts: 95
|
|
I am handling the validations in the action class itself..I have just created a separate method named validate() in each action class
This is how I call the validate() method.And if validation error exsist then the control returns back to the page where I redirect using findForward().But the problem is that I can't see the error messages.
|
 |
Sumit Patil
Ranch Hand
Joined: May 25, 2009
Posts: 296
|
|
Ok, sorry to mis-interpret your question.
Is "common.file.err" present in your properties file?
|
 |
Ayan Biswas
Ranch Hand
Joined: Jul 10, 2010
Posts: 95
|
|
Here is what I have written in my properties file.
|
 |
Sumit Patil
Ranch Hand
Joined: May 25, 2009
Posts: 296
|
|
In the validate method, you are adding errors, but not saving it.
Please save all the errors.
This might be of help
|
 |
Ayan Biswas
Ranch Hand
Joined: Jul 10, 2010
Posts: 95
|
|
|
@Sumit Patel thanks..its exactly what I was looking for
|
 |
Sumit Patil
Ranch Hand
Joined: May 25, 2009
Posts: 296
|
|
Ayan Biswas wrote:... Patel..
Its Patil
|
 |
Ayan Biswas
Ranch Hand
Joined: Jul 10, 2010
Posts: 95
|
|
|
Oh!Really sorry!!
|
 |
 |
|
|
subject: Valdation through action class in struts 1.2
|
|
|