You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Mattox <mi...@verideon.com> on 2003/03/25 15:36:59 UTC
using Tokens with Tiles
I'm trying to prevent the user from submitting a form and then doing a
refresh and unknowingly submitting it twice. I've read the about Struts
support for tokens, and I understand how to use it when an action is called
before the form is displayed. But in my case no action is called before the
form is displayed and I don't know where to call saveToken(request). Is it
possible to use a token in this situation? If not is there another approach
I can use?
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: using Tokens with Tiles
Posted by Michael Mattox <mi...@verideon.com>.
The class is DefinitionDispatcherWithTokenAction and it's FINAL!! Ugh. So
much for extending it.
> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> Sent: mardi 25 mars 2003 16:00
> To: Struts Users Mailing List
> Subject: Re: using Tokens with Tiles
>
>
> I you want to keep this URL style, you should extend
> [forward.do]Action (I don't know the class name) to set a token,
> and define a new mapping in struts-config.xml
> "setTokenAndForward.do" that you can use the same way on page that need a
> token to be set :
> http://localhost:8080/webapp/setTokenAndForward.do?def=main
>
> Nico.
>
> > I'm using Tiles to display the pages, with the Tiles forward.do action
> > passing in the def parameter:
> >
> > http://localhost:8080/webapp/forward.do?def=main
> >
> > I guess I could add a Struts action for every tile definition
> but I really
> > like there has to be a better way!
> >
> > > -----Original Message-----
> > > From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> > > Sent: mardi 25 mars 2003 15:45
> > > To: Struts Users Mailing List
> > > Subject: Re: using Tokens with Tiles
> > >
> > >
> > > You should ALWAYS use an action to display a page. I know lot it
> > > looks simplier to use JSP URL instead of defining a new
> > > action in struts-config... But in your case you see that not
> > > using the controler brings you to duplicate submit
> > > problems.
> > >
> > > Nico.
> > >
> > >
> > > > I'm trying to prevent the user from submitting a form and
> then doing a
> > > > refresh and unknowingly submitting it twice. I've read the
> about Struts
> > > > support for tokens, and I understand how to use it when an
> > > action is called
> > > > before the form is displayed. But in my case no action is
> > > called before the
> > > > form is displayed and I don't know where to call
> > > saveToken(request). Is it
> > > > possible to use a token in this situation? If not is there
> > > another approach
> > > > I can use?
> > > >
> > > > Michael
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: using Tokens with Tiles
Posted by Nicolas De Loof <ni...@cgey.com>.
I you want to keep this URL style, you should extend [forward.do]Action (I don't know the class name) to set a token,
and define a new mapping in struts-config.xml "setTokenAndForward.do" that you can use the same way on page that need a
token to be set :
http://localhost:8080/webapp/setTokenAndForward.do?def=main
Nico.
> I'm using Tiles to display the pages, with the Tiles forward.do action
> passing in the def parameter:
>
> http://localhost:8080/webapp/forward.do?def=main
>
> I guess I could add a Struts action for every tile definition but I really
> like there has to be a better way!
>
> > -----Original Message-----
> > From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> > Sent: mardi 25 mars 2003 15:45
> > To: Struts Users Mailing List
> > Subject: Re: using Tokens with Tiles
> >
> >
> > You should ALWAYS use an action to display a page. I know lot it
> > looks simplier to use JSP URL instead of defining a new
> > action in struts-config... But in your case you see that not
> > using the controler brings you to duplicate submit
> > problems.
> >
> > Nico.
> >
> >
> > > I'm trying to prevent the user from submitting a form and then doing a
> > > refresh and unknowingly submitting it twice. I've read the about Struts
> > > support for tokens, and I understand how to use it when an
> > action is called
> > > before the form is displayed. But in my case no action is
> > called before the
> > > form is displayed and I don't know where to call
> > saveToken(request). Is it
> > > possible to use a token in this situation? If not is there
> > another approach
> > > I can use?
> > >
> > > Michael
> > >
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: using Tokens with Tiles
Posted by Michael Mattox <mi...@verideon.com>.
I'm using Tiles to display the pages, with the Tiles forward.do action
passing in the def parameter:
http://localhost:8080/webapp/forward.do?def=main
I guess I could add a Struts action for every tile definition but I really
like there has to be a better way!
> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> Sent: mardi 25 mars 2003 15:45
> To: Struts Users Mailing List
> Subject: Re: using Tokens with Tiles
>
>
> You should ALWAYS use an action to display a page. I know lot it
> looks simplier to use JSP URL instead of defining a new
> action in struts-config... But in your case you see that not
> using the controler brings you to duplicate submit
> problems.
>
> Nico.
>
>
> > I'm trying to prevent the user from submitting a form and then doing a
> > refresh and unknowingly submitting it twice. I've read the about Struts
> > support for tokens, and I understand how to use it when an
> action is called
> > before the form is displayed. But in my case no action is
> called before the
> > form is displayed and I don't know where to call
> saveToken(request). Is it
> > possible to use a token in this situation? If not is there
> another approach
> > I can use?
> >
> > Michael
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: using Tokens with Tiles
Posted by Nicolas De Loof <ni...@cgey.com>.
You should ALWAYS use an action to display a page. I know lot it looks simplier to use JSP URL instead of defining a new
action in struts-config... But in your case you see that not using the controler brings you to duplicate submit
problems.
Nico.
> I'm trying to prevent the user from submitting a form and then doing a
> refresh and unknowingly submitting it twice. I've read the about Struts
> support for tokens, and I understand how to use it when an action is called
> before the form is displayed. But in my case no action is called before the
> form is displayed and I don't know where to call saveToken(request). Is it
> possible to use a token in this situation? If not is there another approach
> I can use?
>
> Michael
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: using Tokens with Tiles
Posted by Andrew Hill <an...@gridnode.com>.
Good point. (Im not a tile user myself so forgot about that one).
Subclassing would probably be the way to go. Just set the token in execute
and then call super.excecute() and should work. (Not that Ive tried mind
you!)
-----Original Message-----
From: Michael Mattox [mailto:michael.mattox@verideon.com]
Sent: Tuesday, 25 March 2003 22:54
To: Struts Users Mailing List
Subject: RE: using Tokens with Tiles
> You could always have just a single BasicAction class that merely sets a
> token and forwards to the jsp - and reuse this action class in the various
> mappings wherever a less generic one isnt required.
That's what I'm doing with the Tiles forward action. Maybe I should
subclass it and do a saveToken instead?
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: using Tokens with Tiles
Posted by Michael Mattox <mi...@verideon.com>.
> You could always have just a single BasicAction class that merely sets a
> token and forwards to the jsp - and reuse this action class in the various
> mappings wherever a less generic one isnt required.
That's what I'm doing with the Tiles forward action. Maybe I should
subclass it and do a saveToken instead?
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: using Tokens with Tiles
Posted by Andrew Hill <an...@gridnode.com>.
Not sure if its possible (probably not).
In any case Id strongly suggest you make the effort to put actions before
your JSPs as a matter of course - even if they do next to nothing!
Its considered better (best?) practice for a variety of reasons (especially
if your also using submodules) - and is also useful in situations like this
to do some logics before hitting the view...
You could always have just a single BasicAction class that merely sets a
token and forwards to the jsp - and reuse this action class in the various
mappings wherever a less generic one isnt required.
-----Original Message-----
From: Michael Mattox [mailto:michael.mattox@verideon.com]
Sent: Tuesday, 25 March 2003 22:37
To: Struts Users Mailing List
Subject: using Tokens with Tiles
I'm trying to prevent the user from submitting a form and then doing a
refresh and unknowingly submitting it twice. I've read the about Struts
support for tokens, and I understand how to use it when an action is called
before the form is displayed. But in my case no action is called before the
form is displayed and I don't know where to call saveToken(request). Is it
possible to use a token in this situation? If not is there another approach
I can use?
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org