This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Struts and the fly likes Handling Ajax response in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Handling Ajax response in struts2" Watch "Handling Ajax response in struts2" New topic
Author

Handling Ajax response in struts2

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Hi All,

I have an AJax call in a Jacascript function which would go to an Action class. Based on the value sent I need to send back an ArrayList, in short I want to know how to handle an Ajax response and the best way to send value from action class.


amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 540
Hi,
You can convert that List into JSONArray or JSONObject and write the same on OutputStream.
On the client side , in success event handler ( Whatever you choose to implement Ajax on Client Side), parse the JSON String JS libraries and use it further to fulfill the requirements.

Refer http://json.organd http://jquery.com/.

Regards,
Amit
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Actually in action class I have like this...



"Selectedconcept" is what is passed in the Ajax call... Based on that I need to populate attributes of th passed value and they are stored in that json and the name I gave is "atVal...

I am stuck in defining the struts.xml and populating with that List...

I added Json plugin and gave like this...


in jsp...



where atVal is my Json name...


what are the changes required?? My first attempt at JSON and it's all sea!
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Handling Ajax response in struts2
 
jQuery in Action, 3rd edition