Hi, validate=true forces Struts to call the validate method in the ActionForm (or DynaValidatorForm) you wrote when your form is submitted. Make sure what you put there are simple input validation NOT business logic.
You set validate=false when you dont want the validate method to be called. Regards, -Yves- On Tue, 28 Sep 2004 13:47:07 -0400, Tom Holmes Jr. <[EMAIL PROTECTED]> wrote: > Hi Yves, I found out what the problem is. There was an error in my page > where it lists this other path/file. I was intrigued by your statement > about the validate=true. So, I started out with a much simpler page to > experiment with your statement. In that situation I made some simple > pahes to jump to and they worked, so that problem is solved. > > So, I have to ask, should I do validate=true or false? What are the > differences between the two? I was starting out with a basic > application based on "Jakarta Struts for Dummies" and when they showed > the struts-config.xml file, validate-true, but they still coded the > MemberAction with the code I described. > > Anyway, I am going to do some more tests about the validation. > > Thanks for the help. > > Tom > > Yves Sy wrote: > > > Hi Tom, > > > > > > Now you've got this all mixed up. You dont need to call: > > > > ActionErrors errors = ((MemberNewForm)form).validate(mapping,request); > > > > ..in your Action class anymore because Struts will automatically call > > validate for you when you submit your form and you specify > > validate=true in your struts-config (which you did). If there is an > > error in validation, struts will take you back to the page you specify > > in the "input" attribute. > > > > HTH, > > -Yves- > > > > > > On Mon, 27 Sep 2004 11:54:19 -0400, Tom Holmes Jr. <[EMAIL PROTECTED]> wrote: > > > >> > So i dont really understand what you mean when you say that it comes > >> > back to MemberAction and you explicitly call > >> > mapping.findForward("failure"). You're not supposed to call > >> > ActionForm.validate() from your Action class if that's what you did. > >> > >>There is a "validate" method in the MemberNewForm. This code validates > >>some of the data from the form, so if a field is not filled in or has an > >>incorrect length, etc. We return a list of errors to the MemberAction. > >>This is some of the code in the MemberNewForm to validate the data from > >>the form. Is it not right to do this? > >> > >>public ActionErrors validate(ActionMapping mapping, HttpServletRequest > >>request){ > >>ActionErrors errors = new ActionErrors(); > >>if((username == null) || (username.length() < 1)) > >>{ > >>errors.add("username", new ActionError("error.username.required")); > >>} > >> > >>And here is what I have in my action form. I call the "validate" method > >> in the formbean above from the MemberAction. > >> > >>ActionErrors errors = ((MemberNewForm)form).validate(mapping,request); > >>if(errors.isEmpty()) > >>{ > >>// if there are no errors then do whatever ... > >>} > >>else > >>{ > >>// if there are errors, put them in the request header > >>saveErrors(request, errors); > >>// if errors return to the 'failure' which is the same page as the form > >>return (mapping.findForward("failure")); > >>} > >> > >>I didn't know there should be a validate method, in the MemberAction. I > >>haven't seen any samples of that, but that just means I haven't see > >>that. I may not be looking hard enough. > >> > >>So, since I am manually calling "failure" by doing: > >>return (mapping.findForward("failure")); > >>And since this is mapped to a particular path/file, then I should be > >>going to that page and not re-directed elsewhere. > >> > >>Thanks. > >> > >> Tom > >> > >>Yves Sy wrote > >> > >> > >> > >>>Hi, > >>> > >>> > >>> > >>>>Actually both, in my code when the validate is false, then it comes back > >>>>to the MemberAction controller and I do explicitity call: > >>>>return mapping.findForward("failure"); > >>> > >>> > >>>According to the actionmapping you provided, validate = true. So this > >>>means that struts will call validate() automatically for you and > >>>return you to whatever page you specify in "input" if you have errors > >>>in your validation. > >>> > >>>So i dont really understand what you mean when you say that it comes > >>>back to MemberAction and you explicitly call > >>>mapping.findForward("failure"). You're not supposed to call > >>>ActionForm.validate() from your Action class if that's what you did. > >>> > >>>HTH, > >>>-Yves- > >>> > >>>On Sun, 26 Sep 2004 14:45:01 -0400, Tom Holmes Jr. <[EMAIL PROTECTED]> wrote: > >>> > >>> > >>>>Yves Sy wrote: > >>>> > >>>> > >>>>>What do you mean "failure"? You explicitly return > >>>>>mapping.findForward("failure")? Or do you mean when the validate > >>>>>method in ActionForm fails? > >>>> > >>>>Actually both, in my code when the validate is false, then it comes back > >>>>to the MemberAction controller and I do explicitity call: > >>>>return mapping.findForward("failure"); > >>>> > >>>> > >>>> > >>>>>And what's the path of the page where you're being redirected? > >>>> > >>>>it should be redirecting to: > >>>>path="/membership/membership_ee.jsp" > >>>>as defined by: > >>>><forward name="failure" path="/membership/membership_ee.jsp"/> > >>>> > >>>>This is the page where the user entered the wrong data, and I want to > >>>>redirect them back to that page. > >>>> > >>>>Instead, I end up getting sent to another page that's: > >>>>"../message_president/default.jsp" > >>>> > >>>>It expects this page is located in this directory, but it doesn't and I > >>>>don't want to forward to here anyway. The directory and page do exist, > >>>>but elsewhere in the web-site and it not related to my membership > >>>>information. > >>>> > >>>>I tried to find if something was mis-configured, but I can't find out > >>>>what. I'll keep working to figure it out even if I have to go back to > >>>>something simpler to make it work. > >>>> > >>>>Thanks for the information. > >>>> > >>>> Tom > >>>> > >>>> > >>>> > >>>>>-Yves- > >>>>> > >>>>>On Sat, 25 Sep 2004 13:03:58 -0400, Tom Holmes Jr. <[EMAIL PROTECTED]> wrote: > >>>>> > >>>>> > >>>>> > >>>>>>I've been working on this Member pages for a short time now, and it used > >>>>>>to be that when the data didn't validate from the formbean, it would > >>>>>>return to the correct page to allow the user to fix the data. When the > >>>>>>data is entered correctly, the data does gets filed to the database, and > >>>>>>the user is returned to the correct page saying that data has been > >>>>>>filed. Here is the action mapping: > >>>>>> > >>>>>><action path="/membership_ee" > >>>>>> type="com.tjh.csaa.beans.MemberAction" > >>>>>> name="memberNewForm" > >>>>>> scope="request" > >>>>>> input="/membership/membership_ee.jsp" > >>>>>> validate="true"> > >>>>>><forward name="failure" path="/membership/membership_ee.jsp"/> > >>>>>><forward name="success" path="/membership/membership_created.jsp"/> > >>>>>> > >>>>>>This hasn't changed at all, and it used to work fine. And it still does > >>>>>>work if the return is "success". But, when I return "failure", I get > >>>>>>re-directed to some other page that doesn't exist in this directory. I > >>>>>>don't know why it would start doing that all of a sudden? > >>>>>> > >>>>>>Any help would be much appreciated. Thanks! > >>>>>> > >>>>>> Tom > >>>>>> > >>>>>>--------------------------------------------------------------------- > >>>>>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>>>For additional commands, e-mail: [EMAIL PROTECTED] > >>>>>> > >>>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>--------------------------------------------------------------------- > >>>> > >>>> > >>>>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>>>For additional commands, e-mail: [EMAIL PROTECTED] > >>>> > >>>> > >>> > >>> > >>> > >>> > >> > >>--------------------------------------------------------------------- > >> > >> > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- For me to poop on! http://www.formetopoopon.com http://www.nbc.com/nbc/Late_Night_with_Conan_O'Brien/video/triumph.shtml --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]