• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Struts 2 JSON plugin change in finding the target action instance problem

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there!

Recently I've upgraded our struts2 framework and its related plugins (in particular, the json plugin) from version 2.1.8 to version 2.3.16.3.
Now I'm having problems in using the json plugin while making json requests and returning the json responses.
The problem is that the parameter values passed in the json request are not set on my struts 2 action any more (likewise, the return fields set in my action are not returned as a json string).
Why does this happen? The problem is that a change has been made in the newer version of json plugin regarding to how the target action is found.

1. Consider this method:



from the older version of the json plugin (2.1.8):

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-json-plugin/2.1.8/org/apache/struts2/json/JSONInterceptor.java?av=f

line 100:



now from the newer plugin:

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-json-plugin/2.3.16.3/org/apache/struts2/json/JSONInterceptor.java?av=f

line 91:



2. Returning the target action's fields as the json return result:

consider this method:



from the older plugin version 2.1.8:

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-json-plugin/2.1.8/org/apache/struts2/json/JSONResult.java?av=f

line 195:



from the newer plugin:

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-json-plugin/2.3.16.3/org/apache/struts2/json/JSONResult.java?av=f

line 175:



line 187:



line 193:



It is not clear to me why the logic of finding the target action has changed to popping up the value from the top of the stack.
In our case this approach does not work anymore, since we have a custom interceptor pushed onto the top of the stack.

Is there any official workaround? Any explanation why this has changed?

For the moment, the only workaround I've found is specifying the 'root' attribute (with 'action' value) both on the json interceptor and each of the json results. But I'm not sure if it's the right approach.

Thanks

 
Bartender
Posts: 9566
12
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch
I don't know of anyone here who would have that kind of insight into the design decisions of the Struts developers. You may be able to get some insight from searching the Struts 2 Issue Tracker, where the devs track all proposed changes and the developer mailing list, where the devs discuss how to fix said issues. I don't know how receptive the dev list is to questions about design decisions.
 
Pavel Ilyushko
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link!

For those interested, there is an issue about this in their Jira:

https://issues.apache.org/jira/browse/WW-3498

also, I asked the same question on the Struts User mail list, you can view the dialog here:

http://markmail.org/thread/k6css2sp5iouljcz

Regards,

Pavel
 
Nothing? Or something? Like this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!