History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: WW-677
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jason Carreira
Reporter: Michael Campbell
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
WebWork

ww:include replaces existing value stack with new one

Created: 18/Nov/04 04:12 PM   Updated: 18/Dec/04 08:56 AM
Component/s: Views
Affects Version/s: 2.2
Fix Version/s: 2.1.7

File Attachments: 1. Java Source File DispatcherServlet.java (2 kb)



 Description  « Hide
We have an action (call it "JspAction") which, via xwork.xml,
dispatches to our jsp ("test.jsp").

WITHIN test.jsp, we <ww:include> another action (call it
"IncludedAction"), which renders some text (call that "included.jsp").

Here's the behavior we're seeing:

<!-- test.jsp -->
[0]: <ww:property value="[0]" /><br>
[1]: <ww:property value="[1]"/><br>

<ww:include action="included" />

[0]: <ww:property value="[0]" /><br>
[1]: <ww:property value="[1]"/><br>

<!-- cut here -->

We see this:

[0]: [JspAction]
[1]: <blank>

<!-- inluded text from included.jsp -->

[0]: [IncludedAction]
[1]: <blank>

=================

My understanding is that, after the include, [0] has both the
IncludedAction and the JspAction and [1] should have "JspAction"; that
is, included action just gets pushed on to the stack. But what we're
seeing is that the JspAction is just gone - it's not anywhere on the
stack that I can see.

What's worse, if we we wrap the whole thing with a <ww:push ...> to
EXPLICITLY put something on the stack it gets lost after the include
too; we see this:

[0]: [pushed thing, JspAction]
[1]: [JspAction]

<!-- inluded text from included.jsp -->

[0]: [IncludedAction]
[1]: <blank>

 All   Comments   Change History      Sort Order:
Simone Bordet - [25/Nov/04 10:18 AM ]
The problem shows also with using <jsp:include ... /> tag, not only with <ww:include ... />.

Simone Bordet - [27/Nov/04 05:16 AM ]
Jason,
here's the result of my findings:

1. The OgnlValueStack is recreated new on each include. This is not good since it must keep track of the enclosing action.
The reason is that in ServletDispatcher.serveAction() the value stack is not passed into the extraContext map, and therefore (down the invacations) DefaultActionInvocation.createContextMap() creates it every time.

2. The action is pushed into the value stack in DefaultActionInvocation.init(), but never popped out of it.
The best place I've found to pop the action is in a finally block that wraps proxy.execute() in ServletDispatcher.serviceAction(). See attached file.

3. I recommend not to use static methods in ServletDispatcher, as it can be subclassed.
For example, make createContextMap() non static and move the implementation into a utility method somewhere else (that can be static). This way createContextMap() can be overridden, and new stuff added to the map, if the user wants so. Right now is impossible.

4. There is a reason to put the value stack in the request ? It is used only in few places, e.g. TagUtils.getStack(), which is IMHO better replaced by ActionContext.getContext().getValueStack(), like the other 95% of the code.

4. Finally I attach a modified version of ServletDispatcher that solves the issue, but I'm not sure if it breaks others (for what I can say, it seems to work fine, but then I'm only using JSP as views).

Thanks a lot,

Simon

Andrei Ivanov - [18/Dec/04 08:40 AM ]
I think this broke my setup (I'm using velocity).
The vm:

0: $stack.findValue('[0]')<br>
1: $stack.findValue('[1]')<br>
#includeservlet('listShipmentTabs.action')
0: $stack.findValue('[0]')<br>
1: $stack.findValue('[1]')<br>

Output:
0: [com.transbility.web.action.ShipmentStatusAction@14e70f2]
1: []

<included action output>

0: [com.transbility.web.action.ShipmentStatusAction@14e70f2]
1: []

The output is the same, using xw-1.0.4/ww-2.1.6 or xw-1.0.5/ww-2.1.7, but the behaviour is still different.

In the browseShipmentStatus, a list of statuses is created and displayed. The hole list of statuses is sent back to the action class, modified and displayed again.

The problem is that the properties that were modified in the action are overwritten by the values in the form. If I don't include the listShipmentTabs.action, all is fine, but If I do, it seems that the parameters that are set on it override the ones in the parent action also.

Jason Carreira - [18/Dec/04 08:56 AM ]
Andrei,

I don't understand the issue... Can you give more detail? Either send a note to the mailing list (dev@webwork.dev.java.net) or create a new Jira issue.