• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DWR and JSON

 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Frank Zammetti
Ranch Hand
Posts: 136
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic