You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Zheng, Xiahong" <Xi...@FMR.COM> on 2007/12/12 20:06:44 UTC

Strut2: How to determine if a request is a form submission?

 
Hi, 

I am trying to write an action to support a simple form submission work
flow. The "execute" and "prepare" methods will differ depending on
whether it's form submission or initial rendering of the form. On the
initial rendering, the "prepare" method will load the model from DB. On
form submission, the model object will be created empty and be populated
from the request. Is there a easy way to know if a request is a result
of form submission or not?

Thanks,
XZ

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


RE: Strut2: How to determine if a request is a form submission?

Posted by "Zheng, Xiahong" <Xi...@FMR.COM>.
Thanks Dave. I just implemented my own interceptor for this purpose. I
just thought for such a common use case (handling simple form
submission), the framework may already have built-in support for it. I
know Spring's SimpleFormController provides such work flow support.

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Wednesday, December 12, 2007 4:34 PM
To: Struts Users Mailing List
Subject: RE: Strut2: How to determine if a request is a form submission?

When I did this I wrote an interceptor that did various things based on
the
request type; it was a bit more involved but underneath it all that was
just
checking for GET v. POST. You could use the same idea to set a flag or
whatever (or take it further and call action methods, modify what method
gets
executed, etc.)

d.

--- "Zheng, Xiahong" <Xi...@FMR.COM> wrote:

> OK. Then, what's the best way to set the request method to my action
> class? Is there an MethodAware interface I can use. I try to avoid
> working with HttpServletRequest class which I can get by implementing
> ServletRequestAware interface.
> 
> -----Original Message-----
> From: Dave Newton [mailto:newton.dave@yahoo.com] 
> Sent: Wednesday, December 12, 2007 4:02 PM
> To: Struts Users Mailing List
> Subject: Re: Strut2: How to determine if a request is a form
submission?
> 
> POST v. GET, assuming all your form submissions are POSTs?
> 
> --- "Zheng, Xiahong" <Xi...@FMR.COM> wrote:
> 
> >  
> > Hi, 
> > 
> > I am trying to write an action to support a simple form submission
> work
> > flow. The "execute" and "prepare" methods will differ depending on
> > whether it's form submission or initial rendering of the form. On
the
> > initial rendering, the "prepare" method will load the model from DB.
> On
> > form submission, the model object will be created empty and be
> populated
> > from the request. Is there a easy way to know if a request is a
result
> > of form submission or not?
> > 
> > Thanks,
> > XZ
> > 
> >
---------------------------------------------------------------------
> > 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
> 
> 
> 
> ---------------------------------------------------------------------
> 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



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


RE: Strut2: How to determine if a request is a form submission?

Posted by Dave Newton <ne...@yahoo.com>.
When I did this I wrote an interceptor that did various things based on the
request type; it was a bit more involved but underneath it all that was just
checking for GET v. POST. You could use the same idea to set a flag or
whatever (or take it further and call action methods, modify what method gets
executed, etc.)

d.

--- "Zheng, Xiahong" <Xi...@FMR.COM> wrote:

> OK. Then, what's the best way to set the request method to my action
> class? Is there an MethodAware interface I can use. I try to avoid
> working with HttpServletRequest class which I can get by implementing
> ServletRequestAware interface.
> 
> -----Original Message-----
> From: Dave Newton [mailto:newton.dave@yahoo.com] 
> Sent: Wednesday, December 12, 2007 4:02 PM
> To: Struts Users Mailing List
> Subject: Re: Strut2: How to determine if a request is a form submission?
> 
> POST v. GET, assuming all your form submissions are POSTs?
> 
> --- "Zheng, Xiahong" <Xi...@FMR.COM> wrote:
> 
> >  
> > Hi, 
> > 
> > I am trying to write an action to support a simple form submission
> work
> > flow. The "execute" and "prepare" methods will differ depending on
> > whether it's form submission or initial rendering of the form. On the
> > initial rendering, the "prepare" method will load the model from DB.
> On
> > form submission, the model object will be created empty and be
> populated
> > from the request. Is there a easy way to know if a request is a result
> > of form submission or not?
> > 
> > Thanks,
> > XZ
> > 
> > ---------------------------------------------------------------------
> > 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
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Strut2: How to determine if a request is a form submission?

Posted by "Zheng, Xiahong" <Xi...@FMR.COM>.
OK. Then, what's the best way to set the request method to my action
class? Is there an MethodAware interface I can use. I try to avoid
working with HttpServletRequest class which I can get by implementing
ServletRequestAware interface.

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Wednesday, December 12, 2007 4:02 PM
To: Struts Users Mailing List
Subject: Re: Strut2: How to determine if a request is a form submission?

POST v. GET, assuming all your form submissions are POSTs?

--- "Zheng, Xiahong" <Xi...@FMR.COM> wrote:

>  
> Hi, 
> 
> I am trying to write an action to support a simple form submission
work
> flow. The "execute" and "prepare" methods will differ depending on
> whether it's form submission or initial rendering of the form. On the
> initial rendering, the "prepare" method will load the model from DB.
On
> form submission, the model object will be created empty and be
populated
> from the request. Is there a easy way to know if a request is a result
> of form submission or not?
> 
> Thanks,
> XZ
> 
> ---------------------------------------------------------------------
> 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



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


Re: Strut2: How to determine if a request is a form submission?

Posted by Dave Newton <ne...@yahoo.com>.
POST v. GET, assuming all your form submissions are POSTs?

--- "Zheng, Xiahong" <Xi...@FMR.COM> wrote:

>  
> Hi, 
> 
> I am trying to write an action to support a simple form submission work
> flow. The "execute" and "prepare" methods will differ depending on
> whether it's form submission or initial rendering of the form. On the
> initial rendering, the "prepare" method will load the model from DB. On
> form submission, the model object will be created empty and be populated
> from the request. Is there a easy way to know if a request is a result
> of form submission or not?
> 
> Thanks,
> XZ
> 
> ---------------------------------------------------------------------
> 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