This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 511
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!
 
jQuery in Action, 2nd edition
 
subject: Handling Ajax response in struts2
 
Similar Threads
Migrating Application - From Struts with AJAX to JSF with AJAX
Struts-AJAX issue
Problem while redirecting to action class from AJAX
problem of AJAX with struts
select tag ---> s:autocompleter [struts2]