You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Roger Varley <ro...@googlemail.com> on 2007/04/20 12:44:01 UTC

[S2] (Newbie) Using Preparable

Hi

Can someone please explain the point of the Preparable interceptor and
prepare(). What do I gain over doing everything in the execute()
method of my action. Obviously there must be some advantage otherwise
Preparable wouldn't be there, but I can't see it at the moment.

Regards
Roger

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] (Newbie) Using Preparable

Posted by Martin Gainty <mg...@hotmail.com>.
For Implementation for preparable interface Musachy has a full example 
located at
http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html

The prepare() method may be used in your class such to obtain ID as the
prepare method will execute before the execute() method
prepare method will execute before modification by the interceptors
http://forums.opensymphony.com/thread.jspa;jsessionid=aJxkusYMVFMhXopepi?messageID=4347&#4347

M--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Alexis Pigeon" <pi...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Friday, April 20, 2007 7:06 AM
Subject: Re: [S2] (Newbie) Using Preparable


> Hi Roger,
>
> On 20/04/07, Roger Varley <ro...@googlemail.com> wrote:
>> Hi
>>
>> Can someone please explain the point of the Preparable interceptor and
>> prepare(). What do I gain over doing everything in the execute()
>> method of my action. Obviously there must be some advantage otherwise
>> Preparable wouldn't be there, but I can't see it at the moment.
>
> I'm no Struts-guru, but I've been using Struts2 for the last couple of
> months, and the main advantage I found in using the Preparable
> interface was the ability to execute a certain piece of code whatever
> the method you call in the action. However, if the execute() method is
> the only one you are calling, prepare() is kind of useless then. I
> could have missed other features of the Preparable interface, though.
>
> HTH,
> alexis
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] (Newbie) Using Preparable

Posted by Alexis Pigeon <pi...@gmail.com>.
Hi Roger,

On 20/04/07, Roger Varley <ro...@googlemail.com> wrote:
> Hi
>
> Can someone please explain the point of the Preparable interceptor and
> prepare(). What do I gain over doing everything in the execute()
> method of my action. Obviously there must be some advantage otherwise
> Preparable wouldn't be there, but I can't see it at the moment.

I'm no Struts-guru, but I've been using Struts2 for the last couple of
months, and the main advantage I found in using the Preparable
interface was the ability to execute a certain piece of code whatever
the method you call in the action. However, if the execute() method is
the only one you are calling, prepare() is kind of useless then. I
could have missed other features of the Preparable interface, though.

HTH,
alexis

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org