permaculture playing cards
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Handling Ajax response in struts2" Watch "Handling Ajax response in struts2" New topic

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: 543
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

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 agree. Here's the link:
subject: Handling Ajax response in struts2
jQuery in Action, 3rd edition