Pierre,
this is documented behavior -
http://struts.apache.org/2.x/docs/model-driven-interceptor.html
see the second note, toward the top of the page.
-Wes
On Wed, 2008-08-27 at 00:18 -0400, Pierre Thibaudeau wrote:
> 2008/8/26 Pierre Thibaudeau <[EMAIL PROTECTED]>
>
> > [...] suddenly, on my most recent action, the model does not find its way
> > to the top of the stack, and I cannot find where the problem might be.
> >
>
> I dug deeper into this issue and found something very surprising. The
> strange behaviour centres around the execute() method. I am very tempted to
> call it a severe bug (for Struts 2.1.2)...
>
> To make things simple, I produced a test case (see below): two very simple
> ModelDriven Action classes. The first one works as expected, and pushes the
> Model ("SmallObject") on top of the ValueStack. The second action
> surprisingly fails to push the Model on the stack (though the Model is still
> accessible through the Action being on the stack).
>
> In short, it seems that the model is not pushed on the stack when its value
> is last assigned inside the execute() method!!!
>
> Am I forgetting something, or is this truly a bug?
> It might be worth knowing from others if the same problem occurs with
> version of Struts earlier than 2.1.2.
>
> /************/
> /* /test.jsp */
> /************/
> <html><body>
> Model on the stack: ${foo}<br/>
> Action on the stack: ${model.foo}
> </body></html>
>
> /************/
> /* struts.xml */
> /*************/
> <struts>
> <package name="default" extends="struts-default" abstract="false"
> namespace="/" >
> <default-interceptor-ref name="paramsPrepareParamsStack"/>
> <action name="successfull"
> class="com.myapp.SuccessfullAction"><result>/test.jsp</result></action>
> <action name="failing"
> class="com.myapp.FailingAction"><result>/test.jsp</result></action>
> </package>
> </struts>
>
> /******************/
> /* SmallObject.java */
> /******************/
> public class SmallObject {
> private String foo;
> public String getFoo() { return foo; }
> public SmallObject(String str) { foo = str; }
> }
>
> /*******************/
> /* SuccessfullAction */
> /*******************/
> public class SuccessfullAction extends ActionSupport implements
> ModelDriven<SmallObject>, Preparable {
> private SmallObject obj;
> public SmallObject getModel() { return obj; }
> public void prepare() { obj = new SmallObject("bar"); }
> public String execute() { return SUCCESS; }
> }
>
> /******************/
> /* FailingAction */
> /******************/
> public class FailingAction extends ActionSupport implements
> ModelDriven<SmallObject>, Preparable {
> private SmallObject obj;
> public SmallObject getModel() { return obj; }
> public void prepare() { /* do nothing */ }
> public String execute() {
> obj = new SmallObject("bar");
> return SUCCESS;
> }
> }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]