Re: Action from a Link

2002-07-31 Thread mailinglist

>  Is it possible to kickoff an action from a 'link'. For instance I created
a
> 'Logoff' Action (extends Action) which removes session information and
> forwards the user back to the login page. In the initial hacked together
> prototype I have a logout link (not part of a form) on a page. Is it
> possible to have the link execute the LogoffAction or is the better
solution
> to write a servlet that the performs this logic? I know I could embed
logic
> in the login jsp page that invalidates the session if it exists (which I
> will probably add) but I am curious as to whether it is possible to run an
> action from a link.

If you are working with Struts 1.1, you should read Chap5 from Chuck's
Struts book preview available at the www.serverside.com (this book is really
good :)
Page 21 there is an example with DispatchAction, it allows you to do
something like "foo.do?method=logoff"
However, I don't know if it is the best way to do it.






--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Action from a Link

2002-07-31 Thread Eddie Bush

you mean link like that?  ... yeah - you can 
:-)  You should have any "programatic manipulation" in action classes - 
avoid scriplets in your JSPs.  There's no valid reason to not put code 
into action classes instead of writing scriplets.  It's ... very easy 
;-) Study Struts - the example apps in particular - and hit 
theserverside.com and search for "struts book review" - you'll find 
Chuck's book most is an invaluable asset to learning Struts - especially 
the 1.1 features.  Of course, don't forget to pre-order your copy too!

That sort of behavior belongs in action classes.  You may choose to 
include it directly in the class (if it is simple) or make calls to 
beans (with/without static members) that you instantiate and put in 
application scope (not needed if they are static) on application 
start-up (there was a nice thread about how to approach this that went 
on for about 3 days - ended yesterday I think - search the archive). 
 Either way you go, it shouldn't be in your JSPs :-)

HTH,

Eddie

Ryan Cuprak wrote:

>Hello,
> Is it possible to kickoff an action from a 'link'. For instance I created a
>'Logoff' Action (extends Action) which removes session information and
>forwards the user back to the login page. In the initial hacked together
>prototype I have a logout link (not part of a form) on a page. Is it
>possible to have the link execute the LogoffAction or is the better solution
>to write a servlet that the performs this logic? I know I could embed logic
>in the login jsp page that invalidates the session if it exists (which I
>will probably add) but I am curious as to whether it is possible to run an
>action from a link.
>
>Thanks,
> Ryan
>
>
>--
>To unsubscribe, e-mail:   
>For additional commands, e-mail: 
>



--
To unsubscribe, e-mail:   
For additional commands, e-mail: