aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes DWR and JSON Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "DWR and JSON" Watch "DWR and JSON" New topic
Author

DWR and JSON

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I've been using DWR for a long time, and I'm a big fan! I love the way I can just call a JavaScript function that looks just like my Java Method.

The one area where I've had a little frustration is in working with 3rd party JavaScript Widgets. Many of them require a response in JSON. Is there any way to make DWR integrate with such widgets?


Merrill
Consultant, Sima Solutions
Frank Zammetti
Ranch Hand

Joined: Dec 16, 2004
Posts: 136
I know that there is some work in the next version of DWR to use JSON rather than (or perhaps in addition to, not sure) the custom protocol DWR uses. That might help.

Short of that, I'd suggest a decent library to convert your objects to JSON. Most of the major libraries nowadays provide that functionality. You'll of course have to ensure your object model matches up with what the widgets expect so that conerted to JSON it'll be ready to go. Alternatively, provide a json field on your returned object that is generated via a getJson() method. That way, all your object you get back from DWR will have a JSON representation of themselves. This of course means you'll have to write the code to do that conversion, but that's not too difficult, and it'll let you ensure the JSON is in the format you need,


-- <br />Frank W. Zammetti<br />Founder and Chief Software Architect<br />Omnytex Technologies<br /><a href="http://www.omnytex.com" target="_blank" rel="nofollow">http://www.omnytex.com</a><br />AIM/Yahoo: fzammetti<br />MSN: fzammetti@hotmail.com<br />Author of "Practical Ajax Projects With Java Technology"<br /> (2006, Apress, ISBN 1-59059-695-1)<br />and "JavaScript, DOM Scripting and Ajax Projects"<br /> (2007, Apress, ISBN 1-59059-816-4)<br />Java Web Parts - <a href="http://javawebparts.sourceforge.net" target="_blank" rel="nofollow">http://javawebparts.sourceforge.net</a><br /> Supplying the wheel, so you don't have to reinvent it!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: DWR and JSON
 
Similar Threads
relationship between ajax, dojo,dwr, json
Can't access dwr.util in Jspx page of Spring MVC application
Struts with AJAX
Reimplementing parts of my app with DWR
DWR and JSON