Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question on struts?

 
raymond yadao
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!!!
I'm studying struts now coz my next project will be done in struts.I've tried some tutorials in the net and found it easy and interesting to study.My question is this,if struts uses the ActionForm class to validate users input thru its validate method,would this be better to used rather than javascript?well, in javascript the validation is on the client while in struts you still need to submit it to the server.

thanks.

raymond
 
Ram Kumar Subramaniam
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess this would a business decision or your decision.....
If you validate using javascript then validation would be fast but you would be depending a lot on the browser support(if browser does not support javascript ?? or javascript is disabled ??)
If you validate the same on the serverside using ActionForm etc.. your validation might be slow. Thats it.
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The <validator> element also supports a <javascript> child element that allows you to specify a JavaScript function that can be executed on the client side. In this way, both server-side and client-side validation can be specified in a single location, making maintenance easier.

enjoy
http://www.onjava.com/pub/a/onjava/2002/12/11/jakartastruts.html?page=1
 
prabhakar rao
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Validation can be done thru either client side or server side. But in struts, validations could be done thru ActionForm bean class. This is because, Just imagine like this, you have a login form, user enter a name and password. If the name and password is correct, then absolutely no problem he/she may get successfull page. But what will happen, if the password is wrong. This kind of validation can not be done thru java script. And also when the user click on loginAgain link then you should not diplay blank/empty in the user field. Instead of that you should dislay what he/she entered user name so that they can clarify if the user name is wrong or they enter only password and they can go to success page. This is what I understood from struts. If u want further details on this, refere some struts book or reply me so that I can send the code.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic