Re: DynaValidatorForm and Multi-page Forms
What is the setPage() method? From what class? Are you trying to do a form wizard(multiple pages using one DynaValidatorForm)? If so, I have something like that. But I had to override the reset() method in DynaValidatorForm class.--I am still not sure if this is the most elegant way. (don't have time to investigate further) Let me know if I should post my code. -- Derek - Original Message - From: Seth Milder [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, November 05, 2002 9:55 AM Subject: DynaValidatorForm and Multi-page Forms Since nobody answered my previous posting, I'd just like to know if anyone has been able to get DynaValidatorForm with multiple pages to work without having to use the setPage() method. If so, can you please post an example? Thanks! -- Seth Milder Department of Physics and Astronomy MS 3f3 George Mason University Fairfax, VA http://www.mrseth.org -- Fix reason firmly in her seat, and call to her tribunal every fact, every opinion. Question with boldness even the existence of a God; because, if there be one, he must more approve of the homage of reason, than that of blindfolded fear. Thomas Jefferson -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: DynaValidatorForm and Multi-page Forms
Derek Lin wrote: What is the setPage() method? From what class? Are you trying to do a form wizard(multiple pages using one DynaValidatorForm)? Yes. This is it exactly. If so, I have something like that. But I had to override the reset() method in DynaValidatorForm class.--I am still not sure if this is the most elegant way. (don't have time to investigate further) Let me know if I should post my code. -- Derek In struts-config.xml I have: form-beans form-bean name=dynaRegistrationForm dynamic=true type=org.apache.struts.validator.DynaValidatorForm . . . form-property name=page type=int/ . . . /form-bean /form-beans And in the jsp's I have the typical hidden field: . . . html:form method=GET action=/action/register html:hidden property=page value=2/ . . . But the page will not validate correctly unless I call explicitly the setPage method for the DynaValidatorForm in the Action class, like so: DynaValidatorForm info= (DynaValidatorForm) form; int foof = -1; try{ foof = Integer.parseInt(request.getParameter(page)); info.setPage(foof); }catch(Exception e){ if(!(e instanceof java.lang.NoSuchMethodException)) log.error(e.getMessage(),e); } ActionErrors errors = info.validate(mapping, request); If I do not put the above in the Action code, the info.getPage() always returns zero, so the page is not validated since I have no page=0 in the appropriate places in validation.xml. With the above the first page gets validated correctly but the second also tries to validate every field that has page=2 in validation.xml AND page=1 too, which all fail since those parameters are not being submitted. It is almost like it is forgetting that they were set on the first page. Perhaps the trouble is that the DynaValidatorForm is not being saved in the session? I should not have to do this myself. Right? If you have this working, then by all means post your code. Thanks a bunch! -- Seth Milder Department of Physics and Astronomy MS 3f3 George Mason University Fairfax, VA http://www.mrseth.org -- Sex alleviates tension. Love causes it. -- Woody Allen -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: DynaValidatorForm and Multi-page Forms
Oh I see. In my code, I am validating using the plug-in validator. You are validating in the action class. I haven't tried the things you are doing. Anyone else tried this? -- Derek - Original Message - From: Seth Milder [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, November 05, 2002 11:00 AM Subject: Re: DynaValidatorForm and Multi-page Forms Derek Lin wrote: What is the setPage() method? From what class? Are you trying to do a form wizard(multiple pages using one DynaValidatorForm)? Yes. This is it exactly. If so, I have something like that. But I had to override the reset() method in DynaValidatorForm class.--I am still not sure if this is the most elegant way. (don't have time to investigate further) Let me know if I should post my code. -- Derek In struts-config.xml I have: form-beans form-bean name=dynaRegistrationForm dynamic=true type=org.apache.struts.validator.DynaValidatorForm . . . form-property name=page type=int/ . . . /form-bean /form-beans And in the jsp's I have the typical hidden field: . . . html:form method=GET action=/action/register html:hidden property=page value=2/ . . . But the page will not validate correctly unless I call explicitly the setPage method for the DynaValidatorForm in the Action class, like so: DynaValidatorForm info= (DynaValidatorForm) form; int foof = -1; try{ foof = Integer.parseInt(request.getParameter(page)); info.setPage(foof); }catch(Exception e){ if(!(e instanceof java.lang.NoSuchMethodException)) log.error(e.getMessage(),e); } ActionErrors errors = info.validate(mapping, request); If I do not put the above in the Action code, the info.getPage() always returns zero, so the page is not validated since I have no page=0 in the appropriate places in validation.xml. With the above the first page gets validated correctly but the second also tries to validate every field that has page=2 in validation.xml AND page=1 too, which all fail since those parameters are not being submitted. It is almost like it is forgetting that they were set on the first page. Perhaps the trouble is that the DynaValidatorForm is not being saved in the session? I should not have to do this myself. Right? If you have this working, then by all means post your code. Thanks a bunch! -- Seth Milder Department of Physics and Astronomy MS 3f3 George Mason University Fairfax, VA http://www.mrseth.org -- Sex alleviates tension. Love causes it. -- Woody Allen -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: DynaValidatorForm and Multi-page Forms
Derek Lin wrote: Oh I see. In my code, I am validating using the plug-in validator. You are validating in the action class. I haven't tried the things you are doing. Anyone else tried this? I am using the plug-in validator too. At least I think I am :) I was just following the examples that come with Struts 1.1b, specifically the struts-validator webapp with the MultiRegistrationForm example with the exception that they are not using DynaValidatorForm. -- Seth Milder Department of Physics and Astronomy MS 3f3 George Mason University Fairfax, VA http://www.mrseth.org -- Few men have virtue to withstand the highest bidder. GEORGE WASHINGTON -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org