lukaszlenart commented on a change in pull request #406:
URL: https://github.com/apache/struts/pull/406#discussion_r415539580
##########
File path: plugins/json/src/main/java/org/apache/struts2/json/JSONResult.java
##########
@@ -212,12 +211,22 @@ protected Object readRootObject(ActionInvocation
invocation) {
}
protected Object findRootObject(ActionInvocation invocation) {
+ ValueStack stack = invocation.getStack();
Object rootObject;
if (this.root != null) {
- ValueStack stack = invocation.getStack();
+ LOG.debug("Root was defined as [{}], searching stack for it",
this.root);
rootObject = stack.findValue(root);
} else {
- rootObject = invocation.getStack().peek(); // model overrides
action
+ LOG.debug("Root was not defined, searching for #action");
+ rootObject = stack.findValue("#action");
+ if (rootObject instanceof ModelDriven) {
+ LOG.debug("Action is an instance of ModelDriven, assuming
model is on the top of the stack and using it");
+ rootObject = stack.peek();
+ }
+ if (rootObject == null) {
Review comment:
Right, good point :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]