• 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

Error message

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 93
Python Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 93
Python Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[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
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 93
Python Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic