• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

DWR and JSON

 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
reply
    Bookmark Topic Watch Topic
  • New Topic