This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I have a single ActionFormbean (in request scope) and now there are multiple pages using the same ActionForm Bean. i need to validate all this pages. and all the feilds on all the pages are a SUB SET of Action Form Bean (IN REQUEST SCOPE). I need some help regarding the way to proceed. Thank you. Regards Sai.
With your request, or possibly in your form, include a field that has a value which is unique to each page. Then, when processing a page request, you know from which page the request is originating and can validate only the fields that appear on that page. Given that you know which page the request came from, you can also return the user back to that page if a validation error occurs. I use the validate method within the form, I'm not sure how using the Validator class would affect this approach. hth
If you use ValidatorForm from org.apache.struts.validator package, the page variable is in-built. The validate method is also implemented and it invokes the commons validator by passing the page number. You have to just populate the right page value during form submission. Write your validations in the xml as follows by including the page number: <form name="CustomerForm"> <field property="firstName" page=�2� depends="required"> <arg0 key="customerform.firstname"/> </field> </form> Srikanth Author: Struts Survival Guide - Basics to Best Practices
I tried the suggested solution and I used the page attribute of DynaValidatorForm. But I have a problem. Struts does not recognize that I set the page attribute.
I have a multipage registration form and I build my pages with Tiles. I get the page's value with jsp:useBean and jsp:getProperty. When I set page with jsp:setProperty I get the proper value, but the Struts works with the initialized value, 0. When I try to set page's value in WizardAction (when next or previous event is happened) I get 0 and Struts works also with 0. The scope is session everywhere. I don't understand it. Could anybody helps me?