You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by t t <wa...@yahoo.com> on 2004/10/12 01:06:21 UTC
Help! Problem with "isTokenValid"
Hi, all,
I have a Form in my application, when user click the
"submit" button, an Action class will be called. There
is some code like this in these class. The first time
the user click the button, the error
"error.transaction.token" was shown while the second
time it's ok. Why?
Thanks in advance!
Tong
if (!isTokenValid(request)) {
errors.add(
ActionMessages.GLOBAL_MESSAGE,
new
ActionMessage("error.transaction.token"));
}
|
|
|
if (!errors.isEmpty()) {
this.saveErrors(request, errors);
this.saveToken(request);
return (mapping.getInputForward());
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Help! Problem with "isTokenValid"
Posted by Jason Lea <ja...@kumachan.net.nz>.
You need 2 actions. The first saves a token, then displays the form.
The 2nd action is called when the form is submitted, and the code below
looks ok.
I assume you either don't have an action to populate the form (eg the
user opens the .jsp form directly), or the action does not save the token.
When your action to process the form checks for a valid token, the token
doesn't exist, so it is invalid and you return your error message.
t t wrote:
>Hi, all,
>
>I have a Form in my application, when user click the
>"submit" button, an Action class will be called. There
>is some code like this in these class. The first time
>the user click the button, the error
>"error.transaction.token" was shown while the second
>time it's ok. Why?
>Thanks in advance!
>Tong
>
>if (!isTokenValid(request)) {
> errors.add(
> ActionMessages.GLOBAL_MESSAGE,
> new
>ActionMessage("error.transaction.token"));
> }
> |
> |
> |
>
>if (!errors.isEmpty()) {
> this.saveErrors(request, errors);
> this.saveToken(request);
> return (mapping.getInputForward());
> }
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam? Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
--
Jason Lea
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org