Re: page validation in wizzard app
Hi Richard I have aotovalidation turned on - it means that after reset method of my form bean validate() is called, and if it sucessfull action's execute() is invoked. But whatever i do in validate of my form bean is my business. For me autovalidation means that validate() of form bean is invoked in specific moment not by me but by struts. I do alter page (page -- if errors are present) as i described in one of my previous messages but i just wanna to know if it is a good practice, and maybe is better solution... Up to now i find turning off autovalidation a good idea and concerning do it. 2006/5/8, Richard Yee [EMAIL PROTECTED]: Jakub, Even though you are using autovalidation, don't you still have a validate() method in your ActionForm that is getting called? Can you alter the page attribute appropriately there (ie. if (errors.size() 0) page--; -Richard Jakub Milkiewicz wrote: Hi Richard. I can't because of autovalidation. Remember that all my action have the same actionForm which is storred in session. If validation fails i am forwarded to previous action but this action is not even executed cause before this previous action can be invoked validation process occurs. Page parameter isn't changed and validation process fails again... If validation fails i do not enter any action's execute() method. 2006/5/7, Richard Yee [EMAIL PROTECTED]: Jakub, Why can't you reset the page attribute to the appropriate value in your Action classes when validation fails. -Richard Richard Yee wrote: Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - 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
Re: page validation in wizzard app
Hi Quinn I do not understand division of responsibilities. Remember that i have a wizzard application and i do not make any operations as i think ACTION should do. I just need to collect data from screens, validate them - what actuall actionform does, and prepare data to show on next view - retrieve something from DB and put in html:select on next jsp. So ACTION will do nothing except for forwarding to Populate. I think that doubling number of actions will just create mess and won't help maintance in the future. Up to now the best soulution ( as i think) is to turn off autovalidation and validate in Action classes calling actionForm validate(). Obviously i will set proper value of page property in each action before validation. 2006/5/8, Quinn Stone [EMAIL PROTECTED]: You can use the flow: POPULATE1- JSP1 - ACTION1 - POPULATE2 - JSP2 - ACTION2 - POPULATE3 - JSP3 All of the POPULATE actions have validate=false in the config. So, if validation fails after JSP2 is submitted, it forwards to POPULATE2 (ACTION2 has input=POPULATE2 set), which won't try to validate. It makes for more (2x!) actions, but also groups actions logically. POPULATE2 gets things ready for JSP2, and ACTION2 does something with the form from JSP2, and doesn't care about JSP3 at all. That way, you can move the xxx2 page somewhere else, and just have to change the mapping in the config (assuming they're not named 1, 2, 3, that could get a little confusing). Not sure you'd want to change things at this point, but that's one way to approach the problem. Q -Original Message- From: Jakub Milkiewicz [mailto:[EMAIL PROTECTED] Sent: Sunday, May 07, 2006 2:14 PM To: Struts Users Mailing List Subject: Re: page validation in wizzard app Hi Richard. I can't because of autovalidation. Remember that all my action have the same actionForm which is storred in session. If validation fails i am forwarded to previous action but this action is not even executed cause before this previous action can be invoked validation process occurs. Page parameter isn't changed and validation process fails again... If validation fails i do not enter any action's execute() method. 2006/5/7, Richard Yee [EMAIL PROTECTED]: Jakub, Why can't you reset the page attribute to the appropriate value in your Action classes when validation fails. -Richard Richard Yee wrote: Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set
Re: page validation in wizzard app
On 5/8/06, Jakub Milkiewicz [EMAIL PROTECTED] wrote: Up to now the best soulution ( as i think) is to turn off autovalidation and validate in Action classes calling actionForm validate(). Obviously i will set proper value of page property in each action before validation. Turning off autovalidation is a first step to gain more control on your wizard's flow. You may want to check out wizard example in Struts Dialogs 2.0 [1]. The live demo is available [2] It does not use Validator, though. [1] https://sourceforge.net/project/showfiles.php?group_id=49385package_id=154597 [2] http://www.superinterface.com/strutsdialog/wizardaction.do Michael. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: page validation in wizzard app
Jakub, Can you send a sample of your validate method in your form bean? Just to be clear, when you say autovalidation is turned on, you mean that you have validate=true in your action? How do you have the form tags configured in your validation.xml? Also, have you considered using ValidatorActionForm instead of ValidatorForm? From the Validator documentation. Another alternative is to use the action mapping you are currently on by extending the ValidatorActionForm instead of the ValidatorForm. The ValidatorActionForm uses the action element's path attribute from the struts-config.xml which should match the form element's name attribute in the validator-rules.xml. Then a separate action can be defined for each page in a multi-page form and the validation rules can be associated with the action and not a page number as in the example of a multi-page form in the validator example. -Richard -Original Message- From: Jakub Milkiewicz [mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] ] Sent: Monday, May 08, 2006 11:20 AM To: Struts Users Mailing List Subject: Re: page validation in wizzard app Hi Richard I have aotovalidation turned on - it means that after reset method of my form bean validate() is called, and if it sucessfull action's execute() is invoked. But whatever i do in validate of my form bean is my business. For me autovalidation means that validate() of form bean is invoked in specific moment not by me but by struts. I do alter page (page -- if errors are present) as i described in one of my previous messages but i just wanna to know if it is a good practice, and maybe is better solution... Up to now i find turning off autovalidation a good idea and concerning do it. 2006/5/8, Richard Yee [EMAIL PROTECTED]: Jakub, Even though you are using autovalidation, don't you still have a validate() method in your ActionForm that is getting called? Can you alter the page attribute appropriately there (ie. if (errors.size() 0) page--; -Richard Jakub Milkiewicz wrote: Hi Richard. I can't because of autovalidation. Remember that all my action have the same actionForm which is storred in session. If validation fails i am forwarded to previous action but this action is not even executed cause before this previous action can be invoked validation process occurs. Page parameter isn't changed and validation process fails again... If validation fails i do not enter any action's execute() method. 2006/5/7, Richard Yee [EMAIL PROTECTED]: Jakub, Why can't you reset the page attribute to the appropriate value in your Action classes when validation fails. -Richard Richard Yee wrote: Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded
Re: page validation in wizzard app
You could have the ActionForward mapped to an Action class in your struts_config.xml file just as easily as a JSP, e.g. forward name=validation_failed action=RepopulateAction/ and then just 'return ActionForward(validation_failed)' if validation failed on page1. HTH, -ed On 5/6/06, Jakub Milkiewicz [EMAIL PROTECTED] wrote: Hi Ed Thanks for an answer. The problem with your idea is: IF validation fails i can not forward to previous JSP! I need to forward to previous action to prepare me a view - retireve something from DB and put it in html:select. I have the same idea to put form.setPage(pageNo) as first thing in each action. Moreover if i disable autovalidation i do not have to make those tricks to decrement page in validate if errors are found. 2006/5/6, Ed Griebel [EMAIL PROTECTED]: Hi Jakub- I'm not sure if I fully understand your pageflow, but here goes. I would turn off automatic validation in struts_config.xml. In each action, one of the first things I would do is call form.setPage(pageNo) and then call form.validate(...), and if there are any errors I'd return an ActionForward corresponding to the previous JSP. I have an app that is very similar to this but I use a DispatchAction and set things as described above and it works well. As to overriding the page variable counter, it's an interesting idea, but you may run into a problem so you'll have to trap it from going below zero, for instance if they keep failing validation on the first screen. One way to find out for sure is to try it out and see how it goes! -ed On 5/6/06, Jakub Milkiewicz [EMAIL PROTECTED] wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - 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]
Re: page validation in wizzard app
Jakub, Why can't you reset the page attribute to the appropriate value in your Action classes when validation fails. -Richard Richard Yee wrote: Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - 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]
Re: page validation in wizzard app
Hi I do not catch it: forward name=validation_failed action=RepopulateAction/ I do not think this synax is ok. The problem is that i use autovalidation. If validation fails i am forwarded to another action specified by input attribute.Let's call it action2. But action2 is never executed because before its execute() method is invoked.Form bean is validated again. Page attribute isn't changed so validation fails and i am forwarded to another action ... That's like this chain go. If i turn off autovalidation i will follow your idea. 2006/5/7, Ed Griebel [EMAIL PROTECTED]: You could have the ActionForward mapped to an Action class in your struts_config.xml file just as easily as a JSP, e.g. forward name=validation_failed action=RepopulateAction/ and then just 'return ActionForward(validation_failed)' if validation failed on page1. HTH, -ed On 5/6/06, Jakub Milkiewicz [EMAIL PROTECTED] wrote: Hi Ed Thanks for an answer. The problem with your idea is: IF validation fails i can not forward to previous JSP! I need to forward to previous action to prepare me a view - retireve something from DB and put it in html:select. I have the same idea to put form.setPage(pageNo) as first thing in each action. Moreover if i disable autovalidation i do not have to make those tricks to decrement page in validate if errors are found. 2006/5/6, Ed Griebel [EMAIL PROTECTED]: Hi Jakub- I'm not sure if I fully understand your pageflow, but here goes. I would turn off automatic validation in struts_config.xml. In each action, one of the first things I would do is call form.setPage(pageNo) and then call form.validate(...), and if there are any errors I'd return an ActionForward corresponding to the previous JSP. I have an app that is very similar to this but I use a DispatchAction and set things as described above and it works well. As to overriding the page variable counter, it's an interesting idea, but you may run into a problem so you'll have to trap it from going below zero, for instance if they keep failing validation on the first screen. One way to find out for sure is to try it out and see how it goes! -ed On 5/6/06, Jakub Milkiewicz [EMAIL PROTECTED] wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid.
Re: page validation in wizzard app
Hi Richard. I can't because of autovalidation. Remember that all my action have the same actionForm which is storred in session. If validation fails i am forwarded to previous action but this action is not even executed cause before this previous action can be invoked validation process occurs. Page parameter isn't changed and validation process fails again... If validation fails i do not enter any action's execute() method. 2006/5/7, Richard Yee [EMAIL PROTECTED]: Jakub, Why can't you reset the page attribute to the appropriate value in your Action classes when validation fails. -Richard Richard Yee wrote: Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - 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]
Re: page validation in wizzard app
On 5/7/06, Jakub Milkiewicz [EMAIL PROTECTED] wrote: Hi I do not catch it: forward name=validation_failed action=RepopulateAction/ I do not think this synax is ok. The forward .../ is inside of a action block in your struts-config.xml, the syntax is approximate and should be enough to give you the idea. The problem is that i use autovalidation. Yes, I understand you want to use autovalidation, but if turn it off and call form.validate() manually it's only a few additional lines in your action classes and will save you a lot of headaches. -ed - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: page validation in wizzard app
Jakub, Even though you are using autovalidation, don't you still have a validate() method in your ActionForm that is getting called? Can you alter the page attribute appropriately there (ie. if (errors.size() 0) page--; -Richard Jakub Milkiewicz wrote: Hi Richard. I can't because of autovalidation. Remember that all my action have the same actionForm which is storred in session. If validation fails i am forwarded to previous action but this action is not even executed cause before this previous action can be invoked validation process occurs. Page parameter isn't changed and validation process fails again... If validation fails i do not enter any action's execute() method. 2006/5/7, Richard Yee [EMAIL PROTECTED]: Jakub, Why can't you reset the page attribute to the appropriate value in your Action classes when validation fails. -Richard Richard Yee wrote: Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - 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]
RE: page validation in wizzard app
You can use the flow: POPULATE1- JSP1 - ACTION1 - POPULATE2 - JSP2 - ACTION2 - POPULATE3 - JSP3 All of the POPULATE actions have validate=false in the config. So, if validation fails after JSP2 is submitted, it forwards to POPULATE2 (ACTION2 has input=POPULATE2 set), which won't try to validate. It makes for more (2x!) actions, but also groups actions logically. POPULATE2 gets things ready for JSP2, and ACTION2 does something with the form from JSP2, and doesn't care about JSP3 at all. That way, you can move the xxx2 page somewhere else, and just have to change the mapping in the config (assuming they're not named 1, 2, 3, that could get a little confusing). Not sure you'd want to change things at this point, but that's one way to approach the problem. Q -Original Message- From: Jakub Milkiewicz [mailto:[EMAIL PROTECTED] Sent: Sunday, May 07, 2006 2:14 PM To: Struts Users Mailing List Subject: Re: page validation in wizzard app Hi Richard. I can't because of autovalidation. Remember that all my action have the same actionForm which is storred in session. If validation fails i am forwarded to previous action but this action is not even executed cause before this previous action can be invoked validation process occurs. Page parameter isn't changed and validation process fails again... If validation fails i do not enter any action's execute() method. 2006/5/7, Richard Yee [EMAIL PROTECTED]: Jakub, Why can't you reset the page attribute to the appropriate value in your Action classes when validation fails. -Richard Richard Yee wrote: Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
Re: page validation in wizzard app
Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: page validation in wizzard app
Hi Jakub- I'm not sure if I fully understand your pageflow, but here goes. I would turn off automatic validation in struts_config.xml. In each action, one of the first things I would do is call form.setPage(pageNo) and then call form.validate(...), and if there are any errors I'd return an ActionForward corresponding to the previous JSP. I have an app that is very similar to this but I use a DispatchAction and set things as described above and it works well. As to overriding the page variable counter, it's an interesting idea, but you may run into a problem so you'll have to trap it from going below zero, for instance if they keep failing validation on the first screen. One way to find out for sure is to try it out and see how it goes! -ed On 5/6/06, Jakub Milkiewicz [EMAIL PROTECTED] wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: page validation in wizzard app
Hi Thanks for your answer but i do not understand what : hidden static 'page' variable in the JSP Please note that if i submit a form i sent it along with page parameter. And if form is not valid i do not go to any JSP page - i am forwarding to previous ACTION. Because of autovalidation i am stuck in validation() method of my session ActionForm. Because page parameter is not modified, my previous action execute method can not be invoked because validation is not sucessful - but it must be sucessful !!!, cause i am in the previous step, where i do not wanna to be interested in validation of properties that must be checked in next step. 2006/5/6, Richard Yee [EMAIL PROTECTED]: Jakub, I think the more elegant solution is to do the validations in the ActionForm validate method and also use a hidden static 'page' variable in the JSP. Your Action.execute method should be fairly small and mainly have code that calls business delegates and that necessary for determining where to forward to. -Richard Jakub Milkiewicz wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: page validation in wizzard app
Hi Ed Thanks for an answer. The problem with your idea is: IF validation fails i can not forward to previous JSP! I need to forward to previous action to prepare me a view - retireve something from DB and put it in html:select. I have the same idea to put form.setPage(pageNo) as first thing in each action. Moreover if i disable autovalidation i do not have to make those tricks to decrement page in validate if errors are found. 2006/5/6, Ed Griebel [EMAIL PROTECTED]: Hi Jakub- I'm not sure if I fully understand your pageflow, but here goes. I would turn off automatic validation in struts_config.xml. In each action, one of the first things I would do is call form.setPage(pageNo) and then call form.validate(...), and if there are any errors I'd return an ActionForward corresponding to the previous JSP. I have an app that is very similar to this but I use a DispatchAction and set things as described above and it works well. As to overriding the page variable counter, it's an interesting idea, but you may run into a problem so you'll have to trap it from going below zero, for instance if they keep failing validation on the first screen. One way to find out for sure is to try it out and see how it goes! -ed On 5/6/06, Jakub Milkiewicz [EMAIL PROTECTED] wrote: Hi I have a wizzard application with 5 screens. All user inputs are collected in one bean, which is named: viewBean and is stored in HTTP session. So each action has the same formBean - viewBean. I use commons-validator and viewBean properties to validate are present in validation.xml with page attributes. ViewBean extends ValidatorForm and it's validation occurs automatically - i have validation set to true for all ACTIONS. The structure of my app is: Populate view - jsp -populate view -jsp -populate view - jsp ... Population of view happens in ACTION class and can consists of retrieving some data from DB, sets these data in HTTP request. After population process i forward to appropriate jsp to give user a chance to fill the form and to present population process results as for example options in html:select. If form is correct i go to another action which populate view for a next screen (jsp). If form is not filled correctly i need to show it again, but i can not forward to jsp - i need to forward to action that prepares the form - that's why i have my input parameter of action tag set to action which populate the view - previous action. I have a problem with page attribute. Please take a look at the sample of processing in my app: ACTION1 - JSP1 -ACTION2 - JSP2 -Action3 -JSP3 ... Let's assume that user submits form in JSP2 to action3. After ActionForm bean population, page property is set to 2. Next, validation fails in Action3 and input parameter of action3 forwards user to ACTION2. Before execute method in Action2 is invoked, ActionForm (viewBean) validation occurs. The page attribute is still set to 2 ! and commons-validator tries to validate properties that has page attribute set to 2.Obviously validation fails and control is forwarded to Action1. Action1 also has validation set to true and validation of ActionForm occurs again with page =2. Validation fails and control is forwarded to ... Does anyone have any idea to solve the problem. My idea is to not to use hidden page parameter in each jsp action but set page property of viewBean in each Action: for ACTION2 sets it to 2, for Action3 sets it to 3 ... and to override validate method in viewBean: public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = super.validate(mapping,request); if(errors != null errors.size() 0 ) page--; return errors; } Maybe someone knows more elegant solution, or maybe architecture of my app isn't valid. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]