You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by akoo <og...@yahoo.com> on 2008/07/02 06:33:55 UTC
Re: ParamPrepareParamsStack interceptor , how does this work???
thanks I think I figured out the problem. I had implemented the model driven
interface, but had it returning a new Product() object instead. It works
now.
The OP's approach is appropriate when using the param-prepare-params
pattern. Sometimes it's essential that the domain objects are
instantiated/loaded in a prepare method prior to setting their params.
eg. #1. if it's impossible for S2 to instantiate it (when there's no
default constructor or an unknown concrete type).
eg. #2.where a parameter is required to load the domain object prior to
setting its it's params
For the OP:
You haven't indicated whether you're using a getter (getProduct()) or
ModelDriven<Product>. It appears to me that your problem is unrelated to
the paramsPrepareParams stack and more related to your parameters name.
The first invocation of the params interceptor will set all params of
your action (productId, name, color etc). In this case, a Product does
not exist but the productId is set.
The prepare method is invoked and your Product created loaded.
The second invocation of the params interceptor will set all params of
your action again (productid, name, color). In this case a Product does
exist, but you're not setting its own parameters.
I suspect you haven't applied the ModelDriven<Product> interface. You
need to use that if you want to call your parameter "name".
Otherwise you need a getProduct() method with param names such as
"product.name" and "product.color".
regards,
Jeromy Evans
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
--
View this message in context: http://www.nabble.com/ParamPrepareParamsStack-interceptor-%2C-how-does-this-work----tp18184535p18230122.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org