struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom McLaughlin" <>
Subject JSON and RPC without JSON-RPC
Date Thu, 04 Sep 2008 19:57:55 GMT
Hi All,

I've got a javascript front-end that makes asynchronous requests to perform
various CRUD operations.  Ideally, I'd like to write an Action and expose it
directly to my client using JSONUtils to serialize and deserialize my
objects.  The JSON plugin gets me close, but I don't like having to expose
data as a side-effect of calling my Action's methods.  For example,
presently I might have an Action that looks like this...

class PersonAction {
    PersonDAO dao;

    Person person;
    String id;

    public String create(){
        person = dao.create(person);
        return SUCCESS.

    public String retrieve(){

    //getters and setters for person and id go here


But I'd rather have an Action that looks like this...

class PersonAction {
    PersonDAO dao;

    public void create(Person person){
    public Person retrieve(String id) {
        return dao.load(id);

Person would be an entity class, e.g.

class Person {
    String firstName;
    String lastName;
    //getters and setters for firstName and lastName go here...

The SMD annotations in the JSON plugin come close, but I'd like to go the
extra step and not be confined to my client sending "method", "id", and
"params" parameters.  So in the above example I'd post to
/person!create.action with JSON like {firstName : 'Theodore',
lastName:'Koppel'}, i.e. the JSON analogue of my "Person" object.

Has anyone tried anything like this?  I've started looking at creating the
Interceptor and Result classes to support this, but I'd like to know if
other folks are doing similar things and if what I'm seeking to do is even
possible, knowing I'll likely have to develop a plugin to support the idea.
Any thoughts?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message