RE: Form Validation
Try putting max arg, because i think range validation must be supplied with min and max (range) value. arg1 name=intRange key=${var:min} resource=false/ arg2 name=intRange key=${var:max} resource=false/ var var-namemin/var-name var-value${minYear}/var-value /var var var-namemax/var-name var-value${maxYear}/var-value /var CMIIW, bdr. -Original Message- From: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Sent: Monday, March 15, 2004 5:25 PM To: 'Struts Users Mailing List' Subject: SV: Form Validation Thank you, Frank, I was indeed missing the validation='true' but that didn't seem to fix my problem... must be something else; I guess I've got to keep digging. Nina -Ursprungligt meddelande- Från: Otto, Frank [mailto:[EMAIL PROTECTED] Skickat: den 15 mars 2004 11:13 Till: 'Struts Users Mailing List' Ämne: AW: Form Validation Hi Nina, you had to set validation=true in your action definition (struts-config.xml). Regards, Frank -Ursprungliche Nachricht- Von: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Gesendet: Montag, 15. Marz 2004 11:09 An: 'Struts Users Mailing List' Betreff: Form Validation Hi People, I'm pulling my hair out trying to get form validation to work through the validator, any help will be much appreciated. In this example I'm trying to validate a single field (year of type int), should be pretty easy, one might think, but alas, I'm stuck and I can't get it to work. I'm sure it is something simple but I've gone blind from looking at it. Thanks. JSP: html:form action=MyAction.do html:errors/ html:text property=year/ Struts-config: form-beans form-bean name=myForm type=myForm/ /form-beans action path=MyAction type=packageName/MyAction scope=request name=myForm input=myPage.jsp forward name=success path=myPage.jsp/ /action Validation.xml: form name=MyAction field property=year depends=required,integer,intRange arg0 key=MyAction.year/ arg1 name=intRange key=${var:min} resource=false/ var var-namemin/var-name var-value1900/var-value /var /field /form - 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: Form Validation
Ok, next try... i think it'll be because you haven't put the onsubmit javascript code on the html:form tag? something like html:form action=MyAction.do onsubmit=return validateMyForm(this); and put this tag after the end of html:form: html:javascript formName=myForm/ also check if the generated html result have javascript code appended, and the message resource does exist, including the key and value. happy debugging :) -Original Message- From: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Sent: Monday, March 15, 2004 5:45 PM To: 'Struts Users Mailing List' Subject: SV: Form Validation Sorry, yes, it does extend ValidatorForm : ) -Ursprungligt meddelande- Från: Otto, Frank [mailto:[EMAIL PROTECTED] Skickat: den 15 mars 2004 11:41 Till: 'Struts Users Mailing List' Ämne: AW: Form Validation Does your form class extend the ValidatorForm? -Ursprüngliche Nachricht- Von: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Gesendet: Montag, 15. März 2004 11:39 An: 'Struts Users Mailing List' Betreff: SV: Form Validation Thanks Budi, but that didn't seem to do the trick either. When I enter 4 (min range is 1900) in the year field I still don't get an error. -Ursprungligt meddelande- Från: Budi Rostiarso [mailto:[EMAIL PROTECTED] Skickat: den 15 mars 2004 11:31 Till: Struts Users Mailing List Ämne: RE: Form Validation Try putting max arg, because i think range validation must be supplied with min and max (range) value. arg1 name=intRange key=${var:min} resource=false/ arg2 name=intRange key=${var:max} resource=false/ var var-namemin/var-name var-value${minYear}/var-value /var var var-namemax/var-name var-value${maxYear}/var-value /var CMIIW, bdr. -Original Message- From: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Sent: Monday, March 15, 2004 5:25 PM To: 'Struts Users Mailing List' Subject: SV: Form Validation Thank you, Frank, I was indeed missing the validation='true' but that didn't seem to fix my problem... must be something else; I guess I've got to keep digging. Nina -Ursprungligt meddelande- Från: Otto, Frank [mailto:[EMAIL PROTECTED] Skickat: den 15 mars 2004 11:13 Till: 'Struts Users Mailing List' Ämne: AW: Form Validation Hi Nina, you had to set validation=true in your action definition (struts-config.xml). Regards, Frank -Ursprungliche Nachricht- Von: Nina Bertilsdotter [mailto:[EMAIL PROTECTED] Gesendet: Montag, 15. Marz 2004 11:09 An: 'Struts Users Mailing List' Betreff: Form Validation Hi People, I'm pulling my hair out trying to get form validation to work through the validator, any help will be much appreciated. In this example I'm trying to validate a single field (year of type int), should be pretty easy, one might think, but alas, I'm stuck and I can't get it to work. I'm sure it is something simple but I've gone blind from looking at it. Thanks. JSP: html:form action=MyAction.do html:errors/ html:text property=year/ Struts-config: form-beans form-bean name=myForm type=myForm/ /form-beans action path=MyAction type=packageName/MyAction scope=request name=myForm input=myPage.jsp forward name=success path=myPage.jsp/ /action Validation.xml: form name=MyAction field property=year depends=required,integer,intRange arg0 key=MyAction.year/ arg1 name=intRange key=${var:min} resource=false/ var var-namemin/var-name var-value1900/var-value /var /field /form - 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] - 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
RE: form validation question
It didn't make any difference if I used an action or the JSP for the input attribute. -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 6:55 PM To: Struts Users Mailing List Subject: Re: form validation question Ok, maybe, I'd have to check into struts code to really be certain(input surely has some significance is what i'm thinking..) So just for the heck of it though, what happens if you do say /web/forms/orderForm.jsp instead? Andy Kriger wrote: OrderForm.do = /web/forms/orderForm.jsp That shouldn't make a difference. I like to refer to actions rather than JSPs to minimize the number of things I have to change if a JSP changes to a different JSP or to another action. -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 3:27 PM To: Struts Users Mailing List Subject: Re: form validation question Andy: Any reason why you have the unusual input param..? action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action I woud have thought you'd use this instead: action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/web/forms/orderForm.jsp scope=request forward name=success path=/OrderThanks.do/ /action Regards, Geeta Andy Kriger wrote: I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: form validation question
Looks like there is a functional change or bug in the action input attribute in Struts 1.1 - a forward name must be used instead of the location of a JSP or Action. Not sure why this change happened between 1.1RC and 1.1rel - maybe someone on the Struts dev team can answer? -Original Message- From: Andy Kriger [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 2:46 PM To: Struts Users Mailing List Subject: form validation question I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: form validation question
Andy: What do you see in the source of the html page..? Maybe it is just a question of display not working right..? Geeta Andy Kriger wrote: I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: form validation question
I see an empty page - no HTML, no nothing. It's as if the handoff to the input path never happens, even though the logging informs me that validation failed and the input path is being returned to. When you say 'a question of display not working right', what do you have in mind? -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 3:05 PM To: Struts Users Mailing List Subject: Re: form validation question Andy: What do you see in the source of the html page..? Maybe it is just a question of display not working right..? Geeta Andy Kriger wrote: I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [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: form validation question
Your orderForm does extend ValidatorForm instead of ActionForm right? The struts validator plug-in relies on your forms extending ValidatorForm in order to do server-side validations. Out of curiosity, you may want to see if client-side validation works first. html:form action=SubmitOrder.do onsubmit=return validateOrderForm(this) ... /html:form validator:javascript formName=orderForm/ When the submit button is pressed, if the required field is empty, you should get a message window indicating the field is required. Brian Barnett -Original Message- From: Andy Kriger [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 1:16 PM To: 'Struts Users Mailing List' Subject: RE: form validation question I see an empty page - no HTML, no nothing. It's as if the handoff to the input path never happens, even though the logging informs me that validation failed and the input path is being returned to. When you say 'a question of display not working right', what do you have in mind? -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 3:05 PM To: Struts Users Mailing List Subject: Re: form validation question Andy: What do you see in the source of the html page..? Maybe it is just a question of display not working right..? Geeta Andy Kriger wrote: I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [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]
Re: form validation question
Andy: Any reason why you have the unusual input param..? action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action I woud have thought you'd use this instead: action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/web/forms/orderForm.jsp scope=request forward name=success path=/OrderThanks.do/ /action Regards, Geeta Andy Kriger wrote: I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: form validation question
OrderForm.do = /web/forms/orderForm.jsp That shouldn't make a difference. I like to refer to actions rather than JSPs to minimize the number of things I have to change if a JSP changes to a different JSP or to another action. -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 3:27 PM To: Struts Users Mailing List Subject: Re: form validation question Andy: Any reason why you have the unusual input param..? action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action I woud have thought you'd use this instead: action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/web/forms/orderForm.jsp scope=request forward name=success path=/OrderThanks.do/ /action Regards, Geeta Andy Kriger wrote: I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [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: form validation question
orderForm was extending DynaValidatorForm. I changed this to DynaValidatorActionForm - now the form validates (though it shouldn't - there's a required field missing). Looks like I'm one step closer to a solution. Thank you for the idea. -Original Message- From: Barnett, Brian W. [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 5:10 PM To: 'Struts Users Mailing List' Subject: RE: form validation question Your orderForm does extend ValidatorForm instead of ActionForm right? The struts validator plug-in relies on your forms extending ValidatorForm in order to do server-side validations. Out of curiosity, you may want to see if client-side validation works first. html:form action=SubmitOrder.do onsubmit=return validateOrderForm(this) ... /html:form validator:javascript formName=orderForm/ When the submit button is pressed, if the required field is empty, you should get a message window indicating the field is required. Brian Barnett -Original Message- From: Andy Kriger [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 1:16 PM To: 'Struts Users Mailing List' Subject: RE: form validation question I see an empty page - no HTML, no nothing. It's as if the handoff to the input path never happens, even though the logging informs me that validation failed and the input path is being returned to. When you say 'a question of display not working right', what do you have in mind? -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 3:05 PM To: Struts Users Mailing List Subject: Re: form validation question Andy: What do you see in the source of the html page..? Maybe it is just a question of display not working right..? Geeta Andy Kriger wrote: I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: form validation question
Ok, maybe, I'd have to check into struts code to really be certain(input surely has some significance is what i'm thinking..) So just for the heck of it though, what happens if you do say /web/forms/orderForm.jsp instead? Andy Kriger wrote: OrderForm.do = /web/forms/orderForm.jsp That shouldn't make a difference. I like to refer to actions rather than JSPs to minimize the number of things I have to change if a JSP changes to a different JSP or to another action. -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 3:27 PM To: Struts Users Mailing List Subject: Re: form validation question Andy: Any reason why you have the unusual input param..? action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action I woud have thought you'd use this instead: action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/web/forms/orderForm.jsp scope=request forward name=success path=/OrderThanks.do/ /action Regards, Geeta Andy Kriger wrote: I am having a curious problem with form validation. I submit a form, see in the logs that the form fails to validate, however, the webapp does not return to the input page (I get a blank page with no HTML in it), so I do not see the form with error messages as expected. If I put text in the field, the form does submit correctly and I see the JSP specified in the resulting action chain. The log files have no error messages indicating something is amiss. When validation fails, the subsequent action is definitely not running (I do not see the logging in the execute method). Does anyone have any ideas what could be happening here? Or how I can track down the problem? Below is the relevant info... === STRUTS CONFIG === action path=/OrderForm forward=/web/forms/orderForm.jsp / action path=/SubmitOrder type=MyClass name=orderForm validate=true input=/OrderForm.do scope=request forward name=success path=/OrderThanks.do/ /action action path=/OrderThanks parameter=/web/orderThanks.jsp type=org.apache.struts.actions.ForwardAction/ === orderForm.jsp === logic:messagesPresent html:messages id=err %=err%br/ /html:messages /logic:messagesPresent html:form action=SubmitOrder.do html:text property=firstName styleId=firstName size=20/ html:submit value=Press Me/ /html:form === VALIDATION CONFIG === form name=orderForm field property=firstName depends=required arg0 key=orderForm.firstName.label name=required / /field /form === LOG MESSAGES === [org.apache.struts.action.RequestProcessor][RequestProcessor] Validating input form properties [org.apache.struts.action.RequestProcessor][RequestProcessor] Validation failed, returning to '/OrderForm.do' Andy Kriger | Software Mechanic | Greater Than One, Inc. 28 West 27th Street | 7th Floor | New York, NY 10001 P: 212.252.7197 | F: 212.252.7364 | E: [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]
Re: Form validation errors
snafu, bean:write name=error/ seems to work... On Wed, Jan 21, 2004 at 02:34:18PM -0600, [EMAIL PROTECTED] wrote: I am having trouble accessing messages from a resource bundle when form validation fails. In a jar file under the WEB-INF/lib directory I have the following: net/neospire/extranet/resources/Application.properties inside the properties file I have the following: errors.required={0} is required and in my struts-config.xml I have: message-resources parameter=net.neospire.extranet.resources.Application/ however when I do the following in a JSP: logic:messagesPresent html:messages id=error c:out value=${error}/br/ /html:messages /logic:messagesPresent I just get ${error} output once for each required field left blank instead of the message from the resource bundle. -- Sean Bruton [EMAIL PROTECTED] Senior Engineer Network Services NeoSpire, Inc.www.neospire.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Sean Bruton [EMAIL PROTECTED] Senior Engineer Network Services NeoSpire, Inc.www.neospire.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Form validation errors
Try this to see if it works: logic:messagesPresent html:messages id=error %=error% /html:messages /logic:messagesPresent If the above works, make sure you imported the right tld for core. Core has a JSTL EL tld (c.tld), and a runtime expression tld (crt.tld??) Howsa 'bout showing your tablib import directive and your web.xml taglibs that you have declared too At least the above will spit the diff... i.e., let you know if the problem is with the JSP or the resource bundle. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 1:34 PM To: [EMAIL PROTECTED] Subject: Form validation errors I am having trouble accessing messages from a resource bundle when form validation fails. In a jar file under the WEB-INF/lib directory I have the following: net/neospire/extranet/resources/Application.properties inside the properties file I have the following: errors.required={0} is required and in my struts-config.xml I have: message-resources parameter=net.neospire.extranet.resources.Application/ however when I do the following in a JSP: logic:messagesPresent html:messages id=error c:out value=${error}/br/ /html:messages /logic:messagesPresent I just get ${error} output once for each required field left blank instead of the message from the resource bundle. -- Sean Bruton [EMAIL PROTECTED] Senior Engineer Network Services NeoSpire, Inc.www.neospire.net - 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: Form validation errors
That was it, missing some JSTL TLD's. Thanks. On Wed, Jan 21, 2004 at 02:24:27PM -0700, Richard Hightower wrote: Try this to see if it works: logic:messagesPresent html:messages id=error %=error% /html:messages /logic:messagesPresent If the above works, make sure you imported the right tld for core. Core has a JSTL EL tld (c.tld), and a runtime expression tld (crt.tld??) Howsa 'bout showing your tablib import directive and your web.xml taglibs that you have declared too At least the above will spit the diff... i.e., let you know if the problem is with the JSP or the resource bundle. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 1:34 PM To: [EMAIL PROTECTED] Subject: Form validation errors I am having trouble accessing messages from a resource bundle when form validation fails. In a jar file under the WEB-INF/lib directory I have the following: net/neospire/extranet/resources/Application.properties inside the properties file I have the following: errors.required={0} is required and in my struts-config.xml I have: message-resources parameter=net.neospire.extranet.resources.Application/ however when I do the following in a JSP: logic:messagesPresent html:messages id=error c:out value=${error}/br/ /html:messages /logic:messagesPresent I just get ${error} output once for each required field left blank instead of the message from the resource bundle. -- Sean Bruton [EMAIL PROTECTED] Senior Engineer Network Services NeoSpire, Inc.www.neospire.net - 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] -- Sean Bruton [EMAIL PROTECTED] Senior Engineer Network Services NeoSpire, Inc.www.neospire.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form validation over multiple pages - Solution Found - Weird
Could anyone tell me if I am right in what I think the problem is here? I use a web-filter for ssl. I use form-beans that have session scope in a wizard, one of whose steps requires ssl. However when the ssl step gets intercepted by the web filter, the form-bean that should be in session scope seems to be cleared/re-created. Any ideas as to why? Brian - Original Message - From: Brian McSweeney [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Friday, May 30, 2003 11:04 AM Subject: Re: Form validation over multiple pages - Solution Found - Weird Thanks for the help on this guys. It was good to know people had it working. I've got it to work now. The reason it wasn't working was that for all secure pages I use a ssl filter which takes any request mapped like /secure and sends it over ssl. For example, if I want to send the info for the first jsp I send it to: html:form action=/secure/validateStep1.jspa the weird thing is - the form object isn't staying in session scope if I use the ssl filter and so the second page's validation was failing because the object wasn't in session scope anymore. However, once I removed the secure it works fine. Reading other threads, I think this might be to do with a redirect ( if the filter is doing a re-direct, then a new http request might be getting created and thus a new form object gets created ) Anyway, thanks for all the help, and if anyone knows how I could continue using the filter and keep the form object in session scope I'd really appreciate any ideas! Brian - Original Message - From: Paul Curren [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, May 29, 2003 6:00 PM Subject: Re: Form validation over multiple pages Hi there, I've been doing this exact thing the last couple of days and I have it working. My html:hidden tags looks like - html:hidden property=page value=1/ i.e. only difference is I don't explicitly specify the form name. My form is a DynaValidatorForm and a bug which i've seen from rc1 right up to the May 26 nightly so far means that I need to explicity define the page property on the form e.g. form-property name=page type=java.lang.Integer / Hope this helps, Paul C Brian McSweeney wrote: With a little further investigation I see that the page value does not get set in the validationForm using html:hidden approach as outlined below. Ie, this doen't work: html:hidden name=validateForm property=page value=1 / When I print out the value of the page field in the action, it is still set to zero. How do you set the page property? Also, this seems to imply the validator is VERY shaky over multiple pages. For example, the properties on my second page are marked as required, and they don't get validated in the first action (this seems to show that the page based validation is working), yet on the second page, the associated action tries to validate the page 1 properties!!! Arrrg!! What's going on! Has anyone got this to work? Brian - Original Message - From: Brian McSweeney [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, May 29, 2003 2:42 PM Subject: Form validation over multiple pages Hi all, I'm almost there with using the validator over several pages with a single form. However I'm getting a strange little error. The first page is validating fine, and it doesn't seem to try to validate the info required on the second page - correct. However once I try to validate the second page, the javascript validates correctly, but the server side validation returns an error saying the first page's required field needs validating. I think it might be because I'm not sure how to pass the page parameter to the action. I've tried using a html:hidden tag. Anyway, snippets from the jsps, struts config and validation.xml file are included below. If someone could help me out I'd be very grateful. Thanks very much, Brian. My first jsp named validatestep1.jsp looks like: html:javascript formName=validateForm page=1/ html:form action=/secure/validateStep1.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=1 / table trtdusername/td tdhtml:text name=validateForm property=userName //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form My second jsp named validatestep2.jsp looks like html:javascript formName=validateForm page=2/ html:form action=/secure/validateStep2.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=2 / table tr tdcredit card with no spaces or dashes/td tdhtml:text name
Re: Form validation over multiple pages
With a little further investigation I see that the page value does not get set in the validationForm using html:hidden approach as outlined below. Ie, this doen't work: html:hidden name=validateForm property=page value=1 / When I print out the value of the page field in the action, it is still set to zero. How do you set the page property? Also, this seems to imply the validator is VERY shaky over multiple pages. For example, the properties on my second page are marked as required, and they don't get validated in the first action (this seems to show that the page based validation is working), yet on the second page, the associated action tries to validate the page 1 properties!!! Arrrg!! What's going on! Has anyone got this to work? Brian - Original Message - From: Brian McSweeney [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, May 29, 2003 2:42 PM Subject: Form validation over multiple pages Hi all, I'm almost there with using the validator over several pages with a single form. However I'm getting a strange little error. The first page is validating fine, and it doesn't seem to try to validate the info required on the second page - correct. However once I try to validate the second page, the javascript validates correctly, but the server side validation returns an error saying the first page's required field needs validating. I think it might be because I'm not sure how to pass the page parameter to the action. I've tried using a html:hidden tag. Anyway, snippets from the jsps, struts config and validation.xml file are included below. If someone could help me out I'd be very grateful. Thanks very much, Brian. My first jsp named validatestep1.jsp looks like: html:javascript formName=validateForm page=1/ html:form action=/secure/validateStep1.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=1 / table trtdusername/td tdhtml:text name=validateForm property=userName //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form My second jsp named validatestep2.jsp looks like html:javascript formName=validateForm page=2/ html:form action=/secure/validateStep2.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=2 / table tr tdcredit card with no spaces or dashes/td tdhtml:text name=validateForm property=creditCard //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form in my struts config I have action path=/secure/validateStep1 type=ValidateStep1Action name=validateForm scope=session input=/validatestep1.jsp unknown=false validate=true forward name=success path=/validatestep2.jsp redirect=false / and then action path=/secure/validateStep2 type=ValidateStep2Action name=validateForm scope=session input=/validatestep2.jsp unknown=false validate=true forward name=success path=/validated.jsp redirect=false / In my validation.xml file I have form name=validateForm field property=userName depends=required,minlength page=1 field property=creditCard depends=required,creditCard page=2 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form validation over multiple pages
With a little further investigation I see that the page value does not get set in the validationForm using html:hidden approach as outlined below. Ie, this doen't work: html:hidden name=validateForm property=page value=1 / When I print out the value of the page field in the action, it is still set to zero. How do you set the page property? Also, this seems to imply the validator is VERY shaky over multiple pages. For example, the properties on my second page are marked as required, and they don't get validated in the first action (this seems to show that the page based validation is working), yet on the second page, the associated action tries to validate the page 1 properties!!! I believe the server side validation validates any page = the current page and the client side javascript just validates the current page. David Arrrg!! What's going on! Has anyone got this to work? Brian - Original Message - From: Brian McSweeney [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, May 29, 2003 2:42 PM Subject: Form validation over multiple pages Hi all, I'm almost there with using the validator over several pages with a single form. However I'm getting a strange little error. The first page is validating fine, and it doesn't seem to try to validate the info required on the second page - correct. However once I try to validate the second page, the javascript validates correctly, but the server side validation returns an error saying the first page's required field needs validating. I think it might be because I'm not sure how to pass the page parameter to the action. I've tried using a html:hidden tag. Anyway, snippets from the jsps, struts config and validation.xml file are included below. If someone could help me out I'd be very grateful. Thanks very much, Brian. My first jsp named validatestep1.jsp looks like: html:javascript formName=validateForm page=1/ html:form action=/secure/validateStep1.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=1 / table trtdusername/td tdhtml:text name=validateForm property=userName //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form My second jsp named validatestep2.jsp looks like html:javascript formName=validateForm page=2/ html:form action=/secure/validateStep2.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=2 / table tr tdcredit card with no spaces or dashes/td tdhtml:text name=validateForm property=creditCard //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form in my struts config I have action path=/secure/validateStep1 type=ValidateStep1Action name=validateForm scope=session input=/validatestep1.jsp unknown=false validate=true forward name=success path=/validatestep2.jsp redirect=false / and then action path=/secure/validateStep2 type=ValidateStep2Action name=validateForm scope=session input=/validatestep2.jsp unknown=false validate=true forward name=success path=/validated.jsp redirect=false / In my validation.xml file I have form name=validateForm field property=userName depends=required,minlength page=1 field property=creditCard depends=required,creditCard page=2 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form validation over multiple pages
Hi there, I've been doing this exact thing the last couple of days and I have it working. My html:hidden tags looks like - html:hidden property=page value=1/ i.e. only difference is I don't explicitly specify the form name. My form is a DynaValidatorForm and a bug which i've seen from rc1 right up to the May 26 nightly so far means that I need to explicity define the page property on the form e.g. form-property name=page type=java.lang.Integer / Hope this helps, Paul C Brian McSweeney wrote: With a little further investigation I see that the page value does not get set in the validationForm using html:hidden approach as outlined below. Ie, this doen't work: html:hidden name=validateForm property=page value=1 / When I print out the value of the page field in the action, it is still set to zero. How do you set the page property? Also, this seems to imply the validator is VERY shaky over multiple pages. For example, the properties on my second page are marked as required, and they don't get validated in the first action (this seems to show that the page based validation is working), yet on the second page, the associated action tries to validate the page 1 properties!!! Arrrg!! What's going on! Has anyone got this to work? Brian - Original Message - From: Brian McSweeney [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, May 29, 2003 2:42 PM Subject: Form validation over multiple pages Hi all, I'm almost there with using the validator over several pages with a single form. However I'm getting a strange little error. The first page is validating fine, and it doesn't seem to try to validate the info required on the second page - correct. However once I try to validate the second page, the javascript validates correctly, but the server side validation returns an error saying the first page's required field needs validating. I think it might be because I'm not sure how to pass the page parameter to the action. I've tried using a html:hidden tag. Anyway, snippets from the jsps, struts config and validation.xml file are included below. If someone could help me out I'd be very grateful. Thanks very much, Brian. My first jsp named validatestep1.jsp looks like: html:javascript formName=validateForm page=1/ html:form action=/secure/validateStep1.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=1 / table trtdusername/td tdhtml:text name=validateForm property=userName //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form My second jsp named validatestep2.jsp looks like html:javascript formName=validateForm page=2/ html:form action=/secure/validateStep2.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=2 / table tr tdcredit card with no spaces or dashes/td tdhtml:text name=validateForm property=creditCard //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form in my struts config I have action path=/secure/validateStep1 type=ValidateStep1Action name=validateForm scope=session input=/validatestep1.jsp unknown=false validate=true forward name=success path=/validatestep2.jsp redirect=false / and then action path=/secure/validateStep2 type=ValidateStep2Action name=validateForm scope=session input=/validatestep2.jsp unknown=false validate=true forward name=success path=/validated.jsp redirect=false / In my validation.xml file I have form name=validateForm field property=userName depends=required,minlength page=1 field property=creditCard depends=required,creditCard page=2 - 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: Form validation over multiple pages - Solution Found - Weird
Thanks for the help on this guys. It was good to know people had it working. I've got it to work now. The reason it wasn't working was that for all secure pages I use a ssl filter which takes any request mapped like /secure and sends it over ssl. For example, if I want to send the info for the first jsp I send it to: html:form action=/secure/validateStep1.jspa the weird thing is - the form object isn't staying in session scope if I use the ssl filter and so the second page's validation was failing because the object wasn't in session scope anymore. However, once I removed the secure it works fine. Reading other threads, I think this might be to do with a redirect ( if the filter is doing a re-direct, then a new http request might be getting created and thus a new form object gets created ) Anyway, thanks for all the help, and if anyone knows how I could continue using the filter and keep the form object in session scope I'd really appreciate any ideas! Brian - Original Message - From: Paul Curren [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, May 29, 2003 6:00 PM Subject: Re: Form validation over multiple pages Hi there, I've been doing this exact thing the last couple of days and I have it working. My html:hidden tags looks like - html:hidden property=page value=1/ i.e. only difference is I don't explicitly specify the form name. My form is a DynaValidatorForm and a bug which i've seen from rc1 right up to the May 26 nightly so far means that I need to explicity define the page property on the form e.g. form-property name=page type=java.lang.Integer / Hope this helps, Paul C Brian McSweeney wrote: With a little further investigation I see that the page value does not get set in the validationForm using html:hidden approach as outlined below. Ie, this doen't work: html:hidden name=validateForm property=page value=1 / When I print out the value of the page field in the action, it is still set to zero. How do you set the page property? Also, this seems to imply the validator is VERY shaky over multiple pages. For example, the properties on my second page are marked as required, and they don't get validated in the first action (this seems to show that the page based validation is working), yet on the second page, the associated action tries to validate the page 1 properties!!! Arrrg!! What's going on! Has anyone got this to work? Brian - Original Message - From: Brian McSweeney [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, May 29, 2003 2:42 PM Subject: Form validation over multiple pages Hi all, I'm almost there with using the validator over several pages with a single form. However I'm getting a strange little error. The first page is validating fine, and it doesn't seem to try to validate the info required on the second page - correct. However once I try to validate the second page, the javascript validates correctly, but the server side validation returns an error saying the first page's required field needs validating. I think it might be because I'm not sure how to pass the page parameter to the action. I've tried using a html:hidden tag. Anyway, snippets from the jsps, struts config and validation.xml file are included below. If someone could help me out I'd be very grateful. Thanks very much, Brian. My first jsp named validatestep1.jsp looks like: html:javascript formName=validateForm page=1/ html:form action=/secure/validateStep1.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=1 / table trtdusername/td tdhtml:text name=validateForm property=userName //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form My second jsp named validatestep2.jsp looks like html:javascript formName=validateForm page=2/ html:form action=/secure/validateStep2.jspa onsubmit=return validateValidateForm(this); method=post html:hidden name=validateForm property=page value=2 / table tr tdcredit card with no spaces or dashes/td tdhtml:text name=validateForm property=creditCard //td /tr tr td colspan=2 align=center html:image border=0 page=/images/button_submit.gif/ /td /tr /table /html:form in my struts config I have action path=/secure/validateStep1 type=ValidateStep1Action name=validateForm scope=session input=/validatestep1.jsp unknown=false validate=true forward name=success path=/validatestep2.jsp redirect=false / and then action path=/secure/validateStep2 type=ValidateStep2Action name=validateForm scope=session input=/validatestep2.jsp unknown=false validate=true
RE: form validation question
The values specified in the arg0...arg3 are used by the validator as a replacement for the generic pattern {0}. If you give a closer look to the properties you should import(unless you won't specify yours) when using the validator, one of these will be: {0} is required What the arg0..arg3 causes is actually the value in the {0} to be replaced by what you specify. So in your case you should see something similar to the following: phone(value from bundle) phone.ext(value from bundle) required or phone.ext(value from bundle) required Marco -Original Message- From: Andy Kriger [mailto:[EMAIL PROTECTED] Sent: Thursday, March 20, 2003 11:06 PM To: Struts Users Mailing List Subject: form validation question I have a validation rule that looks like this... field property=phoneExt depends=mask arg0 key=phone/ arg1 key=phone.ext/ var var-namemask/var-name var-value^\s*\d*\s*$/var-value /var /field However, it considers the phoneExt field required. Can anyone tell me why? I want the phoneExt field to be optional, and if filled out, to use the given mask. thx andy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: form validation question
Andy Kriger ([EMAIL PROTECTED]) wrote: I have a validation rule that looks like this... field property=phoneExt depends=mask arg0 key=phone/ arg1 key=phone.ext/ var var-namemask/var-name var-value^\s*\d*\s*$/var-value /var /field However, it considers the phoneExt field required. Can anyone tell me why? I want the phoneExt field to be optional, and if filled out, to use the given mask. I believe this has been answered several times and that you just need the newest validation-rules.xml file which makes mask optional if not filled in, and leave the required up to the depends=required,mask Dan -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Daniel Allen, [EMAIL PROTECTED] http://www.mojavelinux.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The package said 'Windows 95 or better', so I installed Linux - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form Validation
On Thu, Feb 20, 2003 at 10:29:51PM -0500, Ian Hunter wrote: It seems to work right for me. That's nice. Are you saying that after validating a form and upon returning to the input page your form has the data the user entered, without adding any special code (as in manually adding the form to the request)? J. -- Justin F. Knotzke [EMAIL PROTECTED] http://www.shampoo.ca - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form Validation
Justin: There is a html:cancel tag that you can use in your jsp which (according to the docs) will indeed bypass the validate method in the form bean and go directly to the action. In your perform/execute method all you need to do is say something like: if (request.getParameter(org.apache.struts.taglib.html.CANCEL) != null) { return mapping.findForward(cancel); } Btw, I am working with Struts 1.02, maybe there's an even slicker solution with 1.1..:) regards, Geeta Justin F. Knotzke wrote: Hi, I'd like to know if future versions of struts will have the ability to return the form, with it's contents back to the input page after failing a validate. If I am going about it correctly, after performing a validate(), and upon returning with ActionErrors, the form is returned empty to the input page. The obvious 'workaround' is to put the form back into the request. But it would be nice if one didn't have to do this. It would also be nice if struts had a property which you could set (say inside the taglib) to tell validate() to not actually validate, depending on the submit (ie, the user hit cancel no need to validate.. Or is this already possible without having to code it by hand? Thanks Justin. -- Justin F. Knotzke [EMAIL PROTECTED] http://www.shampoo.ca - 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: Form Validation
if (this.isCancelled(request)) { return mapping.findForward(cancel); } Joe -Original Message- From: Geeta Ramani [mailto:[EMAIL PROTECTED]] Sent: Friday, February 21, 2003 9:06 AM To: Struts Users Mailing List Subject: Re: Form Validation Justin: There is a html:cancel tag that you can use in your jsp which (according to the docs) will indeed bypass the validate method in the form bean and go directly to the action. In your perform/execute method all you need to do is say something like: if (request.getParameter(org.apache.struts.taglib.html.CANCEL) != null) { return mapping.findForward(cancel); } Btw, I am working with Struts 1.02, maybe there's an even slicker solution with 1.1..:) regards, Geeta Justin F. Knotzke wrote: Hi, I'd like to know if future versions of struts will have the ability to return the form, with it's contents back to the input page after failing a validate. If I am going about it correctly, after performing a validate(), and upon returning with ActionErrors, the form is returned empty to the input page. The obvious 'workaround' is to put the form back into the request. But it would be nice if one didn't have to do this. It would also be nice if struts had a property which you could set (say inside the taglib) to tell validate() to not actually validate, depending on the submit (ie, the user hit cancel no need to validate.. Or is this already possible without having to code it by hand? Thanks Justin. -- Justin F. Knotzke [EMAIL PROTECTED] http://www.shampoo.ca - 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: Form Validation
It seems to work right for me. - Original Message - From: Justin F. Knotzke [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, February 20, 2003 10:27 PM Subject: Form Validation Hi, I'd like to know if future versions of struts will have the ability to return the form, with it's contents back to the input page after failing a validate. If I am going about it correctly, after performing a validate(), and upon returning with ActionErrors, the form is returned empty to the input page. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Form validation across multiple pages
What about to create a collection of errors with the page references and display a unique error page with the list of the errors and the page where they occurred? Just an idea. Marco -Original Message- From: Larry Zappeterrini [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 12, 2003 7:39 PM To: Struts Users Mailing List Subject: Form validation across multiple pages This question may be more appropriate for the developer's mailing list, but I thought that I would post it here to see what kind of sentiment there is in Struts' user land. I have been attempting to implement a form that spans multiple pages that utilizes Struts' validator plug-in. I create an action in the configuration file and associate a subclass of DispatchAction with the intention of mapping each step in the form to a method in the object. Next, I create forward elements within the action to correspond to a page in the form. This works fine for stepping through the form without errors from start to finish. The problem arises when an error is caught by the validator. The way that validator errors are handled in the RequestProcessor(s) included with Struts is to forward control to whatever resource is specified in the action's input attribute. This may not necessarily be the page on which the error occurred, so the flow of the application is disrupted. The only way around this is to make each step of the process into its own action so that each step has its own input. This is sub optimal in my opinion. I am curious to know if there has been any discussion about addressing this situation. A cursory search of the mail archives for the user and developer lists has turned up nothing. To implement mutliple page form validation in the way that I am envisioning would probably require changes in some core parts of Struts, so I wonder if anyone else would find this desirable. Or maybe I am missing some part of the bigger picture that precludes my suggestion. Any thoughts? Thanks, Larry *** This electronic mail transmission contains confidential and/or privileged information intended only for the person(s) named. Any use, distribution, copying or disclosure by another person is strictly prohibited. *** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form validation with Struts Workflow
Richard, in the action mapping you can specify the attribute validate. This attribute defaults to true in the ActionMapping class. With the Struts Workflow Extension the class ApplicationMapping is used instead of ActionMapping. In this class validate defaults to false. Thus, if you want to switch automatic validation on, you explicitly have to specify validate=true in each action definition. However, I recommend to do without automatic form validation, when using the struts-workflow extension. Here is why: 1. Due to the current implementation of struts and the workflow extension, the form validation is done, before authentication and workflow has been checked. This is not what you want, because authentication and workflow needs to be checked first. 2. You can always call the form.validate() method from the action yourself, which I believe is the much better approach anyway, because most often you need some additional information from an external data source to validate the input (e. g. a password). Obtaining information from external data sources should always be done in the action classes, not in the form beans. If I remember correctly, there is no technical reason why automatic form validation can not be supported. It should be a minor change to eliminate reason (1) in the code. So please let me know, if you really need it. I should soon be able to provide a changed version. --- Matthias PS: I cc'ed to the struts user list, because conversations like this might be relevant to other worklow users, too. Richard Grossman wrote: Hi, I'm starting to work using Struts Workflow but I'm confronted to a big problem. It seem that using the workflow the validate method inside ActionForm are not called !?! is there any configuration or else to enabled this ? Thanks for your help Richard Grossman -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Form validation
this page has links to several tutorials: http://jakarta.apache.org/struts/resources/tutorials.html cheers matthew On Wed, 13 Nov 2002 14:07:52 +0100 Jordan Thomas [EMAIL PROTECTED] wrote: Hi, I am wanting to do a step by step, wizard style interface. Does anyone know of a good tutorial for this? thanks Jordan Jordan Thomas Fraunhofer-Institut fuer Produktionstechnik und Automatisierung (FhG-IPA) Nobelstrasse 12 D-70569 Stuttgart Tel.: +49 (0) 711-970-1187 Fax: +49 (0) 711-970-97-1187 Handi:+49 (0) 150-554-76776 E-mail: [EMAIL PROTECTED] Web: http://www.ipa.fhg.de/ http://www.ipa.fhg.de -- Unix is user friendly. It's just very particular about who it's friends are. -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: Form validation
See the serverside.com -Original Message- From: Jordan Thomas [mailto:jordan;vector7.com.au] Sent: Wednesday, November 13, 2002 4:38 PM To: [EMAIL PROTECTED] Subject: Form validation Hi, I am wanting to do a step by step, wizard style interface. Does anyone know of a good tutorial for this? thanks Jordan Jordan Thomas Fraunhofer-Institut fuer Produktionstechnik und Automatisierung (FhG-IPA) Nobelstrasse 12 D-70569 Stuttgart Tel.: +49 (0) 711-970-1187 Fax: +49 (0) 711-970-97-1187 Handi:+49 (0) 150-554-76776 E-mail: [EMAIL PROTECTED] Web: http://www.ipa.fhg.de/ http://www.ipa.fhg.de -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: Form Validation Errors in ONE line?
I assume you're using html:errors to display the messages. Add this to your message resources file errors.prefix=br/ I believe this requires version 1.1. David From: Dan Tran [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Form Validation Errors in ONE line? Date: Tue, 29 Oct 2002 11:00:01 -0800 Hi I used struts declarative validation, which works quite well for me, but the all errors are concatenated in one line. Is there a way to break them into multiple line on my web page? -Dan _ Choose an Internet access plan right for you -- try MSN! http://resourcecenter.msn.com/access/plans/default.asp -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: Form Validation
I had this problem. What you need to do is to have two actions that point to the same place... Here is an example out of my code... When I use a link to get to the form I call createNew.do... After that, the form action and everything else uses submitNew.do they go to the same place, but createNew has validate=false action path=/createNew parameter= type=com.ebind.plantsec.create.actionCreateNew validate=false name=formNewRequest scope=request forward name=continue path=plantsec.create.new redirect=false / forward name=success path=plantsec.mainmenu redirect=false / /action action path=/submitNew parameter= type=com.ebind.plantsec.create.actionCreateNew name=formNewRequest validate=true input=plantsec.create.new scope=request forward name=continue path=plantsec.create.new redirect=false / forward name=success path=plantsec.mainmenu redirect=false / /action -Original Message- From: kkamholz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 02, 2002 1:52 PM To: struts-user Subject: Form Validation Hey everyone, I'm having some issues with form validation. I click on a link to go to a page with a form on it. However, the validate method gets called when I go to the form page rather than when the form is submitted. Maybe I should be using a link to an action that redirects to the form page, rather than going straight to the jsp. I'm not sure. Does anyone have any input about what I might be doing wrong? Thanks! ~ Keith http://www.buffalo.edu/~kkamholz -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Form Validation
That sounds like it will probably work. Thanks! ~ Keith http://www.buffalo.edu/~kkamholz -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 02, 2002 2:10 PM To: [EMAIL PROTECTED] Subject: RE: Form Validation I had this problem. What you need to do is to have two actions that point to the same place... Here is an example out of my code... When I use a link to get to the form I call createNew.do... After that, the form action and everything else uses submitNew.do they go to the same place, but createNew has validate=false action path=/createNew parameter= type=com.ebind.plantsec.create.actionCreateNew validate=false name=formNewRequest scope=request forward name=continue path=plantsec.create.new redirect=false / forward name=success path=plantsec.mainmenu redirect=false / /action action path=/submitNew parameter= type=com.ebind.plantsec.create.actionCreateNew name=formNewRequest validate=true input=plantsec.create.new scope=request forward name=continue path=plantsec.create.new redirect=false / forward name=success path=plantsec.mainmenu redirect=false / /action -Original Message- From: kkamholz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 02, 2002 1:52 PM To: struts-user Subject: Form Validation Hey everyone, I'm having some issues with form validation. I click on a link to go to a page with a form on it. However, the validate method gets called when I go to the form page rather than when the form is submitted. Maybe I should be using a link to an action that redirects to the form page, rather than going straight to the jsp. I'm not sure. Does anyone have any input about what I might be doing wrong? Thanks! ~ Keith http://www.buffalo.edu/~kkamholz -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: form validation
Okay Strutters, I'm trying to solve the problem of losing my form data if the validate() function finds an error. I have seen in this list that people have suggested having: A) 2 actions each with it's own action mapping, one called before the form is rendered on the JSP (instantiating the corresponding form bean) and action for after the form is submitted. B) 1 action with 2 action mappings (???) - How does the app know which action mapping to use? Am I passing a parameter? So I have tried the first solution, but I'm getting an error on the JSP which says that my form bean is not in scope. My action mappings are as follows: action path=/PreAdd type=com.infomediary.admin.actions.PreAdd name=AddBean scope=session validate=false forward name=preprocess path=/jsp/Add.jsp/ /action action path=/Add type=com.infomediary.admin.actions.Add name=AddBean scope=session input=/jsp/Add.jsp validate=true forward name=success path=/jsp/Next.jsp/ forward name=cancel path=/jsp/Back.jsp/ forward name=failure path=/jsp/Add.jsp/ /action Is it something obvious? How would I implement option 2? Thanks in advance - Two ActionMappings, one with validate=false and the other with validate=true. One Action class should be sufficient, though. -- Ted Husted, Husted dot Com, Fairport NY US -- Developing Java Web Applications with Struts -- Tel: +1 585 737-3463 -- Web: http://husted.com/about/services __ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: form validation
I solved the scope problem on my form bean and have a new problem :) I have a property in the form bean which is a String[]. I have several text input fields on the JSP all using the same property name. However I want the values for each of the text areas to be initialized to a particular index of this property. My JSP tags look like this: (where foo is the String[] property) html:text name=formBean property=foobean:write name=formBean property=foo[1]//html:text Should work right? But my text fields are initiated with - [Ljava.lang.String;@448d Seems like it's displaying the pointer instead of the value...which is initially a blank String. How can I correct? Thanks __ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: form validation
Hello, I don't know the answer to your question, but I have a question for you. How do you know the that the value submitted from the input field html:text name=formBean property=foobean:write name=formBean property=foo[1]//html:text will go into foo[1] and not some other index of foo? Noah On Thu, Jun 06, 2002 at 05:05:10PM -0400, [EMAIL PROTECTED] wrote: I solved the scope problem on my form bean and have a new problem :) I have a property in the form bean which is a String[]. I have several text input fields on the JSP all using the same property name. However I want the values for each of the text areas to be initialized to a particular index of this property. My JSP tags look like this: (where foo is the String[] property) html:text name=formBean property=foobean:write name=formBean property=foo[1]//html:text Should work right? But my text fields are initiated with - [Ljava.lang.String;@448d Seems like it's displaying the pointer instead of the value...which is initially a blank String. How can I correct? Thanks -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: form validation
This input tag was listed first on the page and it is coming back first in the array on the submit... I don't know if the ordering is guaranteed, but so far so good. Noah Levitt [EMAIL PROTECTED] wrote: Hello, I don't know the answer to your question, but I have a question for you. How do you know the that the value submitted from the input field html:text name=formBean property=foobean:write name=formBean property=foo[1]//html:text will go into foo[1] and not some other index of foo? Noah On Thu, Jun 06, 2002 at 05:05:10PM -0400, [EMAIL PROTECTED] wrote: I solved the scope problem on my form bean and have a new problem :) I have a property in the form bean which is a String[]. I have several text input fields on the JSP all using the same property name. However I want the values for each of the text areas to be initialized to a particular index of this property. My JSP tags look like this: (where foo is the String[] property) html:text name=formBean property=foobean:write name=formBean property=foo[1]//html:text Should work right? But my text fields are initiated with - [Ljava.lang.String;@448d Seems like it's displaying the pointer instead of the value...which is initially a blank String. How can I correct? Thanks -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] __ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: form validation
I'm nearly certain that the order is not guaranteed. You may want to use the indexed attribute of html: form fields. http://husted.com/struts/resources/indexed-tags.htm Here's a message I sent earlier today on the subject: http://www.mail-archive.com/struts-user@jakarta.apache.org/msg32975.html You'll want to use String[] instead of Vector, of course. Noah On Thu, Jun 06, 2002 at 05:36:10PM -0400, [EMAIL PROTECTED] wrote: This input tag was listed first on the page and it is coming back first in the array on the submit... I don't know if the ordering is guaranteed, but so far so good. Noah Levitt [EMAIL PROTECTED] wrote: Hello, I don't know the answer to your question, but I have a question for you. How do you know the that the value submitted from the input field html:text name=formBean property=foobean:write name=formBean property=foo[1]//html:text will go into foo[1] and not some other index of foo? Noah On Thu, Jun 06, 2002 at 05:05:10PM -0400, [EMAIL PROTECTED] wrote: I solved the scope problem on my form bean and have a new problem :) I have a property in the form bean which is a String[]. I have several text input fields on the JSP all using the same property name. However I want the values for each of the text areas to be initialized to a particular index of this property. My JSP tags look like this: (where foo is the String[] property) html:text name=formBean property=foobean:write name=formBean property=foo[1]//html:text Should work right? But my text fields are initiated with - [Ljava.lang.String;@448d Seems like it's displaying the pointer instead of the value...which is initially a blank String. How can I correct? Thanks -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] __ Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/ Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Form validation
No. An int won't hold a String no matter how hard you try. Change the type to String, then add some validation, and see what happens. JM -Original Message- From: Jivan, Rajiv [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 4:38 PM To: Struts Users Mailing List Subject: Form validation I have a jsp which has an input field in which the user is supposed to enter only integers. The form bean has a field of type int which is displayed as the default in the input field using html:text ... When the user submits the form I want to validate the input field and make sure its a number. The problem is that if it isn't a number when I display an error message the original content which was entered in the field is lost as it reflects the data in the form bean which is an integer. Is there is way to preserve it? -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 3:07 PM To: 'Struts Users Mailing List' Subject: RE: Need help with Token stuff - URGENT Reid's still in jail. -Original Message- From: JM [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 3:08 PM To: Struts Users Mailing List Subject: RE: Need help with Token stuff - URGENT I promiseits not me. Is that you Reid JM -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 2:46 PM To: 'Struts Users Mailing List' Subject: RE: Need help with Token stuff - URGENT Good lord! This sounds like one of James's joke questions to the list [EMAIL PROTECTED] wrote: Hello guys, I still can't work with token stuff. If I have a JSP page with a menu, and when the user clicks in one option, it goes to another menu, which has a html:form and a submit button with an action associated. Where should I use the token associated methods ? where/when should I call saveToken ? thanks a lot Jefferson -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Form validation
All properties on an ActionForm should be declared as Strings for this very reason. After you have confirmed that only numerals were entered into the field, THEN you can convert it to a business object that uses a binary type, like int. The ActionForm is a buffer for whatever people enter into the form. It is not a business object that you would use to represent the state of your application or use as part of business logic processing. -- Ted Husted, Husted dot Com, Fairport NY US -- Developing Java Web Applications with Struts -- Tel: +1 585 737-3463 -- Web: http://husted.com/about/services Jivan, Rajiv wrote: I have a jsp which has an input field in which the user is supposed to enter only integers. The form bean has a field of type int which is displayed as the default in the input field using html:text ... When the user submits the form I want to validate the input field and make sure its a number. The problem is that if it isn't a number when I display an error message the original content which was entered in the field is lost as it reflects the data in the form bean which is an integer. Is there is way to preserve it? -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 3:07 PM To: 'Struts Users Mailing List' Subject: RE: Need help with Token stuff - URGENT Reid's still in jail. -Original Message- From: JM [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 3:08 PM To: Struts Users Mailing List Subject: RE: Need help with Token stuff - URGENT I promiseits not me. Is that you Reid JM -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 2:46 PM To: 'Struts Users Mailing List' Subject: RE: Need help with Token stuff - URGENT Good lord! This sounds like one of James's joke questions to the list [EMAIL PROTECTED] wrote: Hello guys, I still can't work with token stuff. If I have a JSP page with a menu, and when the user clicks in one option, it goes to another menu, which has a html:form and a submit button with an action associated. Where should I use the token associated methods ? where/when should I call saveToken ? thanks a lot Jefferson -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Form validation
Subject: Re: Form validation From: Vic C [EMAIL PROTECTED] === It is a good practice to make all getters and setters take strings as arguments and return strings. HTTP is string based. Even on Int or Dates or whatever. The tricky part is that internaly they are implemented using native data types like BigDecimal or SQLDateTime (and persisted in a Disconnected RowSet for example). You immplement convert Strings to real data types within the getter if it works or store the wrong answer for a bit. Was that confusing? getters and setters use only string, but inside the bean they are implemented using db native types. (OT: and you can even format in the getter (with commans/decimals), localize dates, etc.) And on a related topic: Of course if you turn on the client side validation, JavaScript will be automaticaly generated to create a pop up Window (you code nothing other than place the JavaScript tag) on a submit to validate a date, #, reg. expression, CreditCard checksum, etc. Vic (Guess where is there an example of doing this?) Jivan, Rajiv wrote: I have a jsp which has an input field in which the user is supposed to enter only integers. The form bean has a field of type int which is displayed as the default in the input field using html:text ... When the user submits the form I want to validate the input field and make sure its a number. The problem is that if it isn't a number when I display an error message the original content which was entered in the field is lost as it reflects the data in the form bean which is an integer. Is there is way to preserve it? -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 3:07 PM To: 'Struts Users Mailing List' Subject: RE: Need help with Token stuff - URGENT Reid's still in jail. -Original Message- From: JM [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 3:08 PM To: Struts Users Mailing List Subject: RE: Need help with Token stuff - URGENT I promiseits not me. Is that you Reid JM -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 2:46 PM To: 'Struts Users Mailing List' Subject: RE: Need help with Token stuff - URGENT Good lord! This sounds like one of James's joke questions to the list [EMAIL PROTECTED] wrote: Hello guys, I still can't work with token stuff. If I have a JSP page with a menu, and when the user clicks in one option, it goes to another menu, which has a html:form and a submit button with an action associated. Where should I use the token associated methods ? where/when should I call saveToken ? thanks a lot Jefferson -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Form Validation Question
How about creating 2 mappings where second mapping will have validation turned off? Mark. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 3:36 PM To: [EMAIL PROTECTED] Subject: Form Validation Question Hello, I'm using a single Action Mapping for both adding and editing an entity. The mapping looks like this: action path=/editAuthorityLevel type=com.wellsfargo.pcsweb.controller.EditAuthorityLevelAction name=authorityLevelForm input=/editAuthorityLevel.jsp scope=request forward name=success path=/editAuthorityLevel.jsp/ /action The idea is, if we come into ../editAuthorityLevel from a link that says Add Authority Level, then there'll be no form parameters, the authorityLevelId consequently will be null, and the EditAuthorityLevelAction class can do nothing in this case. If, on the other hand, we come into ../editAuthorityLevel from a form that says Edit Authority Level, then the form fields (especially authorityLevelId) will not be null. In this case, if looks up the appropriate bean and populates the form with the corresponding values. This works great until I introduce form validation. If I implement the form's validate() method so that it returns a non-empty ActionErrors if required fields are not filled in, then this happens when coming in from the Add Authority Level link. When this happens, Struts skips the EditAuthorityLevelAction class and tries to go directly to ../editAuthorityLevel.jsp. This is bad because EditAuthorityLevelAction populates several page beans that the JSP needs. The central problem is this: I'm using the ActionForm to shuttle data from the Model side to the View side. In one case, it's used to swizzle data out of the model and show it in the JSP's edit form. In the other case, it's used to collect data from the form and send it (through the Action) back to the model. Only in the latter case do I care about form validation. Yet Struts imposes validation in both directions. How do I get around this? Cheers, David A. Ventimiglia Wells Fargo Private Client Services (415) 396-0414 (work) -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Form Validation Question
You can also set validate=false in your mapping, but call the form's validate method in your Action, that way you get to decide when to turn validation on. Of course there's the additional hit of going to the action every time, in this case. Ady -Original Message- From: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 3:45 PM To: 'Struts Users Mailing List' Subject: RE: Form Validation Question How about creating 2 mappings where second mapping will have validation turned off? Mark. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 3:36 PM To: [EMAIL PROTECTED] Subject: Form Validation Question Hello, I'm using a single Action Mapping for both adding and editing an entity. The mapping looks like this: action path=/editAuthorityLevel type=com.wellsfargo.pcsweb.controller.EditAuthorityLevelAction name=authorityLevelForm input=/editAuthorityLevel.jsp scope=request forward name=success path=/editAuthorityLevel.jsp/ /action The idea is, if we come into ../editAuthorityLevel from a link that says Add Authority Level, then there'll be no form parameters, the authorityLevelId consequently will be null, and the EditAuthorityLevelAction class can do nothing in this case. If, on the other hand, we come into ../editAuthorityLevel from a form that says Edit Authority Level, then the form fields (especially authorityLevelId) will not be null. In this case, if looks up the appropriate bean and populates the form with the corresponding values. This works great until I introduce form validation. If I implement the form's validate() method so that it returns a non-empty ActionErrors if required fields are not filled in, then this happens when coming in from the Add Authority Level link. When this happens, Struts skips the EditAuthorityLevelAction class and tries to go directly to ../editAuthorityLevel.jsp. This is bad because EditAuthorityLevelAction populates several page beans that the JSP needs. The central problem is this: I'm using the ActionForm to shuttle data from the Model side to the View side. In one case, it's used to swizzle data out of the model and show it in the JSP's edit form. In the other case, it's used to collect data from the form and send it (through the Action) back to the model. Only in the latter case do I care about form validation. Yet Struts imposes validation in both directions. How do I get around this? Cheers, David A. Ventimiglia Wells Fargo Private Client Services (415) 396-0414 (work) -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Form Validation Question
I would, except I don't know how to turn validation off in the Action Mapping in struts-config.xml. As long as I use the same ActionForm for both show me a blank form so I can add and show me a populated form so I can edit, and that ActionForm implements validate(), then there's validation. Is there a way to turn this off? The alternative, which may not be so bad, is for the validate() method to inspect the form fields and to decide to actually check for empty fields if we're in show me a populated form so I can edit mode. Actually, that's not bad at all because it fits with the overall semantics. In other words, I was originally thinking the validation rule is: The Authentication Level's 'Name' field may not be empty. But upon further reflection, it's clear the validation rule is really: The Authentication Level's 'Name' field may not be empty, UNLESS this is the special case of the 'Insert Row'. Where 'Insert Row' is defined to be a bean whose primary key (eg., authenticationLevelId) is null. Cheers, David -Original Message- From: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 12:45 PM To: 'Struts Users Mailing List' Subject: RE: Form Validation Question How about creating 2 mappings where second mapping will have validation turned off? Mark. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 3:36 PM To: [EMAIL PROTECTED] Subject: Form Validation Question Hello, I'm using a single Action Mapping for both adding and editing an entity. The mapping looks like this: action path=/editAuthorityLevel type=com.wellsfargo.pcsweb.controller.EditAuthorityLevelAction name=authorityLevelForm input=/editAuthorityLevel.jsp scope=request forward name=success path=/editAuthorityLevel.jsp/ /action The idea is, if we come into ../editAuthorityLevel from a link that says Add Authority Level, then there'll be no form parameters, the authorityLevelId consequently will be null, and the EditAuthorityLevelAction class can do nothing in this case. If, on the other hand, we come into ../editAuthorityLevel from a form that says Edit Authority Level, then the form fields (especially authorityLevelId) will not be null. In this case, if looks up the appropriate bean and populates the form with the corresponding values. This works great until I introduce form validation. If I implement the form's validate() method so that it returns a non-empty ActionErrors if required fields are not filled in, then this happens when coming in from the Add Authority Level link. When this happens, Struts skips the EditAuthorityLevelAction class and tries to go directly to ../editAuthorityLevel.jsp. This is bad because EditAuthorityLevelAction populates several page beans that the JSP needs. The central problem is this: I'm using the ActionForm to shuttle data from the Model side to the View side. In one case, it's used to swizzle data out of the model and show it in the JSP's edit form. In the other case, it's used to collect data from the form and send it (through the Action) back to the model. Only in the latter case do I care about form validation. Yet Struts imposes validation in both directions. How do I get around this? Cheers, David A. Ventimiglia Wells Fargo Private Client Services (415) 396-0414 (work) -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Form Validation Question
You can turn off validation by specifying validate=false in your action: !-- invoke action with validation -- actionpath=/path1 type=com... scope=... name=... validate=true input= forward name=success path=/processingPath/ /action !-- invoke the same action but no validation -- actionpath=/path1NV type=com... scope=... name=... validate=false input= forward name=success path=/processingPath/ /action Mark -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 3:57 PM To: [EMAIL PROTECTED] Subject: RE: Form Validation Question I would, except I don't know how to turn validation off in the Action Mapping in struts-config.xml. As long as I use the same ActionForm for both show me a blank form so I can add and show me a populated form so I can edit, and that ActionForm implements validate(), then there's validation. Is there a way to turn this off? The alternative, which may not be so bad, is for the validate() method to inspect the form fields and to decide to actually check for empty fields if we're in show me a populated form so I can edit mode. Actually, that's not bad at all because it fits with the overall semantics. In other words, I was originally thinking the validation rule is: The Authentication Level's 'Name' field may not be empty. But upon further reflection, it's clear the validation rule is really: The Authentication Level's 'Name' field may not be empty, UNLESS this is the special case of the 'Insert Row'. Where 'Insert Row' is defined to be a bean whose primary key (eg., authenticationLevelId) is null. Cheers, David -Original Message- From: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 12:45 PM To: 'Struts Users Mailing List' Subject: RE: Form Validation Question How about creating 2 mappings where second mapping will have validation turned off? Mark. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 3:36 PM To: [EMAIL PROTECTED] Subject: Form Validation Question Hello, I'm using a single Action Mapping for both adding and editing an entity. The mapping looks like this: action path=/editAuthorityLevel type=com.wellsfargo.pcsweb.controller.EditAuthorityLevelAction name=authorityLevelForm input=/editAuthorityLevel.jsp scope=request forward name=success path=/editAuthorityLevel.jsp/ /action The idea is, if we come into ../editAuthorityLevel from a link that says Add Authority Level, then there'll be no form parameters, the authorityLevelId consequently will be null, and the EditAuthorityLevelAction class can do nothing in this case. If, on the other hand, we come into ../editAuthorityLevel from a form that says Edit Authority Level, then the form fields (especially authorityLevelId) will not be null. In this case, if looks up the appropriate bean and populates the form with the corresponding values. This works great until I introduce form validation. If I implement the form's validate() method so that it returns a non-empty ActionErrors if required fields are not filled in, then this happens when coming in from the Add Authority Level link. When this happens, Struts skips the EditAuthorityLevelAction class and tries to go directly to ../editAuthorityLevel.jsp. This is bad because EditAuthorityLevelAction populates several page beans that the JSP needs. The central problem is this: I'm using the ActionForm to shuttle data from the Model side to the View side. In one case, it's used to swizzle data out of the model and show it in the JSP's edit form. In the other case, it's used to collect data from the form and send it (through the Action) back to the model. Only in the latter case do I care about form validation. Yet Struts imposes validation in both directions. How do I get around this? Cheers, David A. Ventimiglia Wells Fargo Private Client Services (415) 396-0414 (work) -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete
RE: Form Validation Question
Thanks! -Original Message- From: Ady Das-O'Toole [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 12:51 PM To: Struts Users Mailing List Subject: RE: Form Validation Question You can also set validate=false in your mapping, but call the form's validate method in your Action, that way you get to decide when to turn validation on. Of course there's the additional hit of going to the action every time, in this case. Ady -Original Message- From: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 3:45 PM To: 'Struts Users Mailing List' Subject: RE: Form Validation Question How about creating 2 mappings where second mapping will have validation turned off? Mark. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 3:36 PM To: [EMAIL PROTECTED] Subject: Form Validation Question Hello, I'm using a single Action Mapping for both adding and editing an entity. The mapping looks like this: action path=/editAuthorityLevel type=com.wellsfargo.pcsweb.controller.EditAuthorityLevelAction name=authorityLevelForm input=/editAuthorityLevel.jsp scope=request forward name=success path=/editAuthorityLevel.jsp/ /action The idea is, if we come into ../editAuthorityLevel from a link that says Add Authority Level, then there'll be no form parameters, the authorityLevelId consequently will be null, and the EditAuthorityLevelAction class can do nothing in this case. If, on the other hand, we come into ../editAuthorityLevel from a form that says Edit Authority Level, then the form fields (especially authorityLevelId) will not be null. In this case, if looks up the appropriate bean and populates the form with the corresponding values. This works great until I introduce form validation. If I implement the form's validate() method so that it returns a non-empty ActionErrors if required fields are not filled in, then this happens when coming in from the Add Authority Level link. When this happens, Struts skips the EditAuthorityLevelAction class and tries to go directly to ../editAuthorityLevel.jsp. This is bad because EditAuthorityLevelAction populates several page beans that the JSP needs. The central problem is this: I'm using the ActionForm to shuttle data from the Model side to the View side. In one case, it's used to swizzle data out of the model and show it in the JSP's edit form. In the other case, it's used to collect data from the form and send it (through the Action) back to the model. Only in the latter case do I care about form validation. Yet Struts imposes validation in both directions. How do I get around this? Cheers, David A. Ventimiglia Wells Fargo Private Client Services (415) 396-0414 (work) -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: form validation
Two ActionMappings, one with validate=false and the other with validate=true. One Action class should be sufficient, though. -- Ted Husted, Husted dot Com, Fairport NY US -- Developing Java Web Applications with Struts -- Tel: +1 585 737-3463 -- Web: http://husted.com/about/services Pritchard, Sean wrote: I've run into a bit of a sticking point on form validation and I'm wondering whether anyone else has encountered this. I have an Action EditUserAction that works with a UserForm to edit a user's data (e.g. first name, last name. email, etc.). In my Action, I check the request for a valid token. If the token is not valid, I get the user's data from the database (via the model layer) and populate the form with it. I then forward control to a jsp that displays the form. If the token is valid, I update the user's data in the database (again via the model layer) with the data in the form. So I use the same Action to initially populate the form and then to process the submitted form. The problem I'm running into, is that I want to begin using form validation. So I created a validate method that ensures the email address is not null or zero-length. The problem is, that the error message is displayed the first time the form is displayed (i.e. before the form is submitted). It seems I should only validate the form when it is submitted rather than the first time it is displayed. It is currently being validated before the user submits it, so if the user has not previously submitted an email address, when they first see the form, the error message Email address is required appears. My current design would call for the form validation to be invoked only when the token is valid. But Struts doesn't seem to lend itself to validating a token within a form (because the token validation methods are protected instance methods of Action). It feels a bit like I'm fighting the direction the framework wants to go, which makes me think my design is flawed. Any suggestions? Should I use two separate actions, one to populate the form and one to process the submit? That would allow me to set validation on one and not the other. Should I check for a valid token inside my validate() method and only look for errors if the token is valid? Thanks in advance for your suggestions. Sean -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: form validation
There are various solutions. I put a hidden variable on my form ( in the formBean) with the form name in it. If it's not there I know not to validate the form data. Some people have 2 Actions Action classes for this but I fear that would lead to too much code duplication. However some of my Action classes are getting a bit big unwieldy. --- Pritchard, Sean [EMAIL PROTECTED] wrote: I've run into a bit of a sticking point on form validation and I'm wondering whether anyone else has encountered this. I have an Action EditUserAction that works with a UserForm to edit a user's data (e.g. first name, last name. email, etc.). In my Action, I check the request for a valid token. If the token is not valid, I get the user's data from the database (via the model layer) and populate the form with it. I then forward control to a jsp that displays the form. If the token is valid, I update the user's data in the database (again via the model layer) with the data in the form. So I use the same Action to initially populate the form and then to process the submitted form. The problem I'm running into, is that I want to begin using form validation. So I created a validate method that ensures the email address is not null or zero-length. The problem is, that the error message is displayed the first time the form is displayed (i.e. before the form is submitted). It seems I should only validate the form when it is submitted rather than the first time it is displayed. It is currently being validated before the user submits it, so if the user has not previously submitted an email address, when they first see the form, the error message Email address is required appears. My current design would call for the form validation to be invoked only when the token is valid. But Struts doesn't seem to lend itself to validating a token within a form (because the token validation methods are protected instance methods of Action). It feels a bit like I'm fighting the direction the framework wants to go, which makes me think my design is flawed. Any suggestions? Should I use two separate actions, one to populate the form and one to process the submit? That would allow me to set validation on one and not the other. Should I check for a valid token inside my validate() method and only look for errors if the token is valid? Thanks in advance for your suggestions. Sean -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] = ~~ Search the archive:- http://www.mail-archive.com/struts-user%40jakarta.apache.org/ ~~ Keith Bacon - Looking for struts work - South-East UK. phone UK 07960 011275 __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: form validation
There are a number of ways to achieve this, and again (!) it's about choice, although I must say this can be confusing for newbie (and experienced!) struts users. 1. 2 Actions, 1 for 'pre' and 1 for 'post' processing 2. An 'action' parameter, with switch behaviour in the action class 3. 'isVirgin()' extension to the Action Form. Option 3 is basically an added method to the ActionForm class that allows the Action to determine if 'pre' or 'post' processing the form, without the need for an 'action' parameter. Consider the following in the Action class, where 'sf' refers to the instance of the form: // determine if pre-processing, and if so continue on to the View if (sf.isVirgin()) return mapping.findForward(ChikiConstants.ACTION_FORWARD_SUCCESS); // getting this far indicates post-processing... /** * Determines if pre or post processing the form.br * Criteria being null indicates pre-processing. * * @return true if pre-processing the form */ public boolean isVirgin () { return ( (criteria == null) ); } The 'isVirgin' method returns true if 'pre' processing the form, and false if 'post' processing. Option 1 gives good seperation, but can lead to an unneccesary proliferation of Action classes in large apps Option 2 achieves the same, but can lead to 'messy' Actions Option 3 needs additional logic in the form, but allows pre and post processing in the one Action - however, this doesn't extend as far as seperate actions and action parameters when you need to do more than just pre and post processing. In our applications we have used all 3 at various times. We tend to use option 3 when we just need the split between pre and post processing, eg a Search or Login action. In more complex sceanrio's we tend to use option 1 or 2. Try to determine which best fits your scenario. Depending on your context, one solution may be better than the other, but this will not be true across the board for all scenarios. Think through your real needs before choosing the solution. With regards to your exact scenario, we developed option 3 as a solution to this very situation, so I would suggest option 3 might be best suited, although you will ultimately have to decide ! Having developed option 3 and implemented it, we have found it to be the most effective way of getting around this. As I previously stated, option 1 and 2 come into their own in other situations. Hope this helps - if you need any more detail let me know, Ghoot -Original Message- From: keithBacon [mailto:[EMAIL PROTECTED]] Sent: 21 February 2002 17:32 To: Struts Users Mailing List Subject: Re: form validation There are various solutions. I put a hidden variable on my form ( in the formBean) with the form name in it. If it's not there I know not to validate the form data. Some people have 2 Actions Action classes for this but I fear that would lead to too much code duplication. However some of my Action classes are getting a bit big unwieldy. --- Pritchard, Sean [EMAIL PROTECTED] wrote: I've run into a bit of a sticking point on form validation and I'm wondering whether anyone else has encountered this. I have an Action EditUserAction that works with a UserForm to edit a user's data (e.g. first name, last name. email, etc.). In my Action, I check the request for a valid token. If the token is not valid, I get the user's data from the database (via the model layer) and populate the form with it. I then forward control to a jsp that displays the form. If the token is valid, I update the user's data in the database (again via the model layer) with the data in the form. So I use the same Action to initially populate the form and then to process the submitted form. The problem I'm running into, is that I want to begin using form validation. So I created a validate method that ensures the email address is not null or zero-length. The problem is, that the error message is displayed the first time the form is displayed (i.e. before the form is submitted). It seems I should only validate the form when it is submitted rather than the first time it is displayed. It is currently being validated before the user submits it, so if the user has not previously submitted an email address, when they first see the form, the error message Email address is required appears. My current design would call for the form validation to be invoked only when the token is valid. But Struts doesn't seem to lend itself to validating a token within a form (because the token validation methods are protected instance methods of Action). It feels a bit like I'm fighting the direction the framework wants to go, which makes me think my design is flawed. Any suggestions? Should I use two separate actions, one to populate the form and one to process
RE: form validation failure and state
if your list is populated dynamically (say, using the options tag) you need to repopulate the collection that you use to populate the list options. you can do this in your reset method. if your list always uses the same values as options, you might try storing these values in the application context, and retrieve the list from there (i think the options tag will do this for you, though i'm not 100% sure) and embed it within your jsp. the difference between the options list and the other form attributes is the other form attributes are submitted to the servlet in the HttpRequest as parameters. however, the options list is not. the only thing submitted from a select is the selectedIndex. ab -Original Message- From: Jon Burford [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 5:48 PM To: [EMAIL PROTECTED] Subject: form validation failure and state I've got a form with text fields and drop down list boxes which is fully populated by an init action before the form is displayed. The user can then make changes and submit the form, which in turn calls the validate function on my form object. If I detect invalid input, I return one or more errors from my validate function and the errors are displayed by struts along with the form they were changing. The problem I am having is that struts seems to remember and populate all the text fields correctly when it redisplays the form with the errors, but the drop downs are empty. I know of a couple ways I could repopulate the drop downs, but I was wondering why struts remembers what's in the text fields, but not in the drop downs? Am I missing something, or is this how it works? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: form validation failure and state
In my experience, struts will repopulate all fields including any drop-down menus but only if they are implemented using the html:select tag. If you are generating the drop-downs without the help of the struts taglib then it cannot repopulate the form. A) Are you using the struts tags for the drop-downs? B) If so does the validate function wipe out the values that would be displayed by the drop down? -Original Message- From: Jon Burford [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 5:48 PM To: [EMAIL PROTECTED] Subject: form validation failure and state I've got a form with text fields and drop down list boxes which is fully populated by an init action before the form is displayed. The user can then make changes and submit the form, which in turn calls the validate function on my form object. If I detect invalid input, I return one or more errors from my validate function and the errors are displayed by struts along with the form they were changing. The problem I am having is that struts seems to remember and populate all the text fields correctly when it redisplays the form with the errors, but the drop downs are empty. I know of a couple ways I could repopulate the drop downs, but I was wondering why struts remembers what's in the text fields, but not in the drop downs? Am I missing something, or is this how it works? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: form validation failure and state
The collections that are used in the drop-down's. Where are they created? If they are created in your init method and stored in request scope. Then they won't be there for the form unless they are created again when the validation fails. You can store these collections in application scope so that they will always be available to the options tag. Another solution would be to make the input attribute in your action mapping the action that creates the collections. -Original Message- From: Jon Burford [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 5:48 PM To: [EMAIL PROTECTED] Subject: form validation failure and state I've got a form with text fields and drop down list boxes which is fully populated by an init action before the form is displayed. The user can then make changes and submit the form, which in turn calls the validate function on my form object. If I detect invalid input, I return one or more errors from my validate function and the errors are displayed by struts along with the form they were changing. The problem I am having is that struts seems to remember and populate all the text fields correctly when it redisplays the form with the errors, but the drop downs are empty. I know of a couple ways I could repopulate the drop downs, but I was wondering why struts remembers what's in the text fields, but not in the drop downs? Am I missing something, or is this how it works? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Form validation before pop-up window openning
Hi, assuming you use validation as done by David's extensions (- validation.xml,...) you could change the Javascript-stuff in the validation.xml file to call the pop-up-window... hope this helps Alexander Jesse -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 12, 2001 9:18 AM To: [EMAIL PROTECTED] Subject: Form validation before pop-up window openning Hi, I have a form with several buttons in it, one of them is a save button, that opens a pop-up window where you fill the name under which you want to save the informations you filled in the opener form. My problem is that I would like to validate the opener window before openning the pop-up window, using the validate(mapping,request) method of my ActionForm. Do you know a way to do so ?? Is it possible to call struts methods in the javascript script that open the pup-up window ?? If I use the same action and actionform for the opener form and the pop-up form, can I validate the openner before openning the pop-up form -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Form validation before pop-up window openning
Xavier, I would probably handle it in multiple steps (veeery personal opinion): - save calls the Action that performs the validation - if the validation fails, return the same page with errors on top (for example) without opening the pop-up - if the validation succeeds, you can return the same page but also generate a body onload= to open the pop-up window via Javascript. In order to call the form.validate(mapping, request) method you need the ActionMapping that is stored on the ActionServlet (to which you have no reference - I hope, at least! :)). And that's probably a good thing: the validation is performed on the ActionForm during the ActionServlet processing and should not be moved too much to the presentation layer. But it's only my point of view... HTH Andrej -Original Message- From: Xavier Brunel [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 12, 2001 3:18 AM To: 'Struts-User Subject: Form validation before pop-up window openning Hi, I have a form with several buttons in it, one of them is a save button, that opens a pop-up window where you fill the name under which you want to save the informations you filled in the opener form. My problem is that I would like to validate the opener window before openning the pop-up window, using the validate(mapping,request) method of my ActionForm. Do you know a way to do so ?? Is it possible to call struts methods in the javascript script that open the pup-up window ?? If I use the same action and actionform for the opener form and the pop-up form, can I validate the openner before openning the pop-up form -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Form Validation Question
You can put in any url in the input attribute. So there isn't a problem having input go through an action. David --- DEHAMER,BRIAN (HP-MountainView,ex1) [EMAIL PROTECTED] wrote: If I want to use form validation with my ActionForm bean, what should I specify for the input attribute of my action defition? Should it reference the JSP page that renders the form (e.g. /login.jsp) or should it reference the action responsible for presenting the form (e.g. /login.do)? All of the examples that I've seen show the input attribute pointing to the JSP page; however, when I do this I notice that my page doesn't render properly because it is dependent on some information that is set in the associated action class. If I put an action path in the input attribute I think I can solve my problem, but I'm not sure if this is an appropriate use of the architecture. Thanks for the help. Brian DeHamer Hewlett-Packard Co. [EMAIL PROTECTED] __ Do You Yahoo!? Listen to your Yahoo! Mail messages from any phone. http://phone.yahoo.com
Re: form validation
Mike Dewhirst [EMAIL PROTECTED] How is it possible to validate input in struts for formatting? What I mean is, is it possible to check when a string is entered into an input field that populates an int? It seems that the Controller populates the int with a 0, which makes it difficult to detect if this was an invalid input, or a real 0. Would we need to extend the framework if we want to be able to detect this? Thanks for any advice!! You can either use String (in this way you can accept inputs like 2.001), or you can use Integer. It will be null, if no correct integer is has been entered. -- gR
RE: form validation
Actually, it returns 0. So there is no way to distinguish between an invalid input or a real 0. What I mean is, is it possible to check when a string is entered into an input field that populates an int? It seems that the Controller populates the int with a 0, which makes it difficult to detect if this was an invalid input, or a real 0. Would we need to extend the framework if we want to be able to detect this? Thanks for any advice!! You can either use String (in this way you can accept inputs like 2.001), or you can use Integer. It will be null, if no correct integer is has been entered. -- gR =** If you are not the intended recipient, employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination or copying of this communication and its attachments is strictly prohibited. If you have received this communication and its attachments in error, please return the original message and attachments to the sender using the reply facility on e-mail. Internet communications are not secure and therefore the UCLES Group does not accept legal responsibility for the contents of this message. Any views or opinions presented are solely those of the author and do not necessarily represent those of the UCLES Group unless otherwise specifically stated. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses although this does not guarantee that this email is virus free. **=
Re: form validation
Many developers recommend that the ActionForm properties all be String, so that validation can be done on just what the user typed, and so that any error messages can display to the user exactly what s/he typed. Yes, the controller can do conversions for you, but I never use that feature. Will - Original Message - From: Mike Dewhirst [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 15, 2001 5:42 AM Subject: form validation How is it possible to validate input in struts for formatting? What I mean is, is it possible to check when a string is entered into an input field that populates an int? It seems that the Controller populates the int with a 0, which makes it difficult to detect if this was an invalid input, or a real 0. Would we need to extend the framework if we want to be able to detect this? Thanks for any advice!!
Re: Form Validation
The validate() method is called by the Action when the validate property for the mapping is true. I have more than one mapping to the same Action. The mapping to create a new form has validate=false. The mapping to insert a form has validate=true. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel 716 737-3463. -- http://www.husted.com/about/struts/ Steve Taylor wrote: When and why is form validation called when the form is instantiated. How are others getting around validation issues when a form should pass validation when there's no data, but not on a save?(i.e. when there's data) Thanks Steve Taylor Systems Consultant Pangaea Systems Inc. (250) 360-0111 http://www.pangaeainc.com