File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Error message" Watch "Error message" New topic
Author

Error message

Vijayalakshmi Karthikeyan
Greenhorn

Joined: Jul 23, 2010
Posts: 27
I am new to struts. I have designed a basic log in form that contains user name and password. I need to perform some validation like if the user did not enter the user name or password., an error message should be displayed as we can do in asp.net using required field validation control. I am able to do with java script. But i have been asked to perform server side validation that is using Struts. Kindly help me.
Apologize me if this is been already posted in the forum or if it is silly question
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

OK. Its hard to read italic, colored text. Make it simple, use default.

Now to your question, If its Struts1, then google Struts commons validator OR use ActionForm#validate() method.

HTH.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88


I assume you are using Struts 1.x. You can do validation in two ways, either using ActionForm validate() method(refer Struts doc site) or by using Validator plugin(which is now a part of Struts).

Using ActionForm validate method, validation has to be written for each form. Whereas by using Validator plugin, setting rules using regex is enough.
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88

I assume you are using Struts 1.x. You can do validation in two ways, either using ActionForm validate() method(refer Struts doc site) or by using Validator plugin(which is now a part of Struts).

Using ActionForm validate method, validation has to be written for each form. Whereas by using Validator plugin, setting rules using regex is enough.

Please note: If you are using Ajax for submitting form, these validations may get bypassed.
Vijayalakshmi Karthikeyan
Greenhorn

Joined: Jul 23, 2010
Posts: 27
[quote=Rajan Jay]I assume you are using Struts 1.x. You can do validation in two ways, either using ActionForm validate() method(refer Struts doc site) or by using Validator plugin(which is now a part of Struts).

Using ActionForm validate method, validation has to be written for each form. Whereas by using Validator plugin, setting rules using regex is enough.

Please note: If you are using Ajax for submitting form, these validations may get bypassed.

Thank you.. But can you guide me with some steps. because am able to locate the validator plugin. But i dont know how to proceed. Also if possible give me sample coding to perform encryption[color=blue]
I would really like to thank the moderator for giving an opportunity for learners. and this is the forum where am getting instant replies. Thank you.[/color].


[/quote]
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Vijayalakshmi Karthikeyan wrote: But can you guide me with some steps. because am able to locate the validator plugin. But i dont know how to proceed.

struts validation tutorial
Vijayalakshmi Karthikeyan
Greenhorn

Joined: Jul 23, 2010
Posts: 27
Hi..
I have some doubts.
1) I have done with validation of fields using action errors. Please Tell me how to reset the errors displayed in JSP page when a browser back button or reset button is pressed
2) Also i could see the fields not reset when the browser back button is pressed.. Guide me in that.
3) There is a reset method in action form class i have written code to clear the fields and error messages. But i dont know how to call the function.
Please answer to my questions. But i think all questions are related to each other :-)
Karthik Jayachandran
Ranch Hand

Joined: Feb 18, 2009
Posts: 88

3) There is a reset method in action form class i have written code to clear the fields and error messages. But i dont know how to call the function.


in your action class. call reset method

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error message