You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lukasz Lenart <lu...@apache.org> on 2023/02/03 07:40:25 UTC

Re: struts2-json-plugin: ExecuteAndWait issue when returning JSON

Sorry for a late reply :(

pt., 20 sty 2023 o 02:28 Kris O'Neil <kr...@petrosys.com.au> napisał(a):

> > Does it mean you have something else on top of the stack than action?

> The original action, held in the background process, is at the top of the stack. This is the object we want returned when "JSONResult.findRootObject" is called. The second object in the stack is the action created by the polling request to get a progress update. The change in 6.0.0 to call 'stack.findValue("#action")' returns the second object in the stack. As the polling action is never executed and instead delegated to the background progress, there's no data returned by the second action i.e. no progress information.

I wonder why stack.findValue("#action") returns the second action not
the top action, I need to investigate this

> > If this is a ModelDriven it should be fine as well as there is a code to detect that.

> I have changed my action to implement ModelDriven to get around the code change to JSONResult. If this is now a requirement of using the ExecuteAndWaitInterceptor, the documentation may need to be updated - https://struts.apache.org/core-developers/execute-and-wait-interceptor

No, it shouldn't be, I would say it's rather a recommendation to use
ModelDriven instead of action itself. As far as I understand, by
implementing ModelDriven you don't have to specify the "root" object
in the JSON result as ModelDriven is used directly, right?

> >> Workaround:
> >> Changing the action to implement 'ModelDriven' reinstates the old behaviour of calling 'stack.peek()' in the JSONResult.findRootObject(...) method.

> > Thanks, but what else can it be?

> Ideally, the action from the background process would be returned by "JSONResult.findRootObject" without the need for the action to implement ModelDriven. Could the ExecuteAndWaitInterceptor add the action to the context with the key 'action'?  I'm not sure if there would be other implications of changing the action in this way.

I will try to dig into that, I understand your concern


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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