Rosh, > I want to use struts validator and just control > validation manually. Why do I need saveErrors() > method and what does it do? Isn't the validator > does all that. I am little confused.
If you are going to call the validation manually, then you will have to perform the same steps the validation framework would do. Those steps are normally performed in chains (or the RequestProcessor if you use and older version) and handle a number of things automatically. Turning the validation off in the Struts config bypasses much of that so you will have to do it manually. Just calling validate gets a list of errors but does nothing with it so it becomes lost if you do not save it somewhere. Check your code and you'll see you do nothing with it and it goes away when you return your mapping.findForward(). You can learn/find out a lot more by reviewing the code from either the source code download OR the online (http/web-based) svn repository at: http://svn.apache.org/viewvc/struts/action/trunk/core/src/main/java/org/apac he/struts/ > The way it is wortkng now: it is giving me null pointer > exception if I hit go in the url for selstate.do action. What is the stack trace? Stack traces show what leads up to the exception so you can figure out what class or object is having the problem. > It is doing client site validation only if i hit submit button. That is how it is supposed to work: client side validation invokes in the submit but should not actually submit anything until you have cleared up all of the client side errors. If you are not seeing that then perhaps you don't have the correct html:javascript formName="..." tag setup properly with the corresponding onSubmit="" for your html:form tag. > public ActionForward execute(ActionMapping mapping, ActionForm form, > HttpServletRequest request, HttpServletResponse response) throws > IOException, ServletException > { > SelStateForm sform = (SelStateForm) form; > String isSubmitted = sform.getIsSubmitted(); > if(isSubmitted == "Yes" || isSubmitted.equalsIgnoreCase("Yes")) > { > ActionErrors errors = sform.validate( mapping, request ); > if((errors != null) && errors.size() > 0) > { > return mapping.findForward(mapping.getInput()); > } > } > return mapping.findForward("success"); > } >} 1) Isn't the method signature supposed to be (note one Exception, not two): public ActionForward execute(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception 2) Is "isSubmitted()" checking some sort of variable in your page? Why do you have it at all? Is this page being called a lot of times for a wizard or something? 3) Have you put any logging statements (commons Logging Log class or even System.out.println) anywhere so you can see/feel the flow of where you are going and what is happening inside your action? You know, to help you debug this yourself? 4) See how you do nothing with the errors object so it simply goes away with garbage collection after you return your mapping? You need to PUT IT somewhere to be used, hence the suggestions of using one of the various saveErrors()/saveMessages() methods where appropriate so it doesn't disappear with Garbage collection and you can get something meaningful out of it which is why you are using validation to obtain/get those errors in the first place. Regards, David --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]