wood burning stoves 2.0*
The moose likes Struts and the fly likes tokens and validations are not playing well Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "tokens and validations are not playing well" Watch "tokens and validations are not playing well" New topic
Author

tokens and validations are not playing well

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Hi.
I'm imploying Struts transaction tokens in order to prevent the user from submitting register form twice.

registerForm is a sub class of ValidatorForm.
The problem is when I type /action/register.do?operation=load
I got register.jsp page which is full of validation errors and Struts generated tokens is not included in the page.
How over come this problem (without turning off the validation) ?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by John Todd:
The problem is when I type /action/register.do?operation=load
I got register.jsp page which is full of validation errors

That's just the problem: When you type in an Action URI, none of the fields have been populated, so naturally validation is going to fail. If you're planning on calling this action both from a URI and from a form submit, you need to define two separate action mappings. They can both refer to the same action class, and have basically the same settings, but they must each have a different path name. The one you call from a URI should specify validate="false" and the one you call from a form submission should specify validate="true". Example:

[ February 14, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

I think DispatchAction will not fit in this situation, right ?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
No, DispatchAction would not fit this situation.
 
jQuery in Action, 2nd edition
 
subject: tokens and validations are not playing well
 
Similar Threads
struts application deployment in tomcat server
struts application in tomcat server
How to find method in Sturts
Error in creation of bean
Struts Validation Problem