You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alejandro Calbazana <al...@calbazana.com> on 2007/02/08 03:39:47 UTC

Struts 1.3, JSON, and Action Forms

Hello,

I am wondering if anyone has made use of Ajax and SON under Struts 1.3...

I'd like to make use of JSON in my Struts application in order to ease 
the process of data binding Dojo widgets.  I'd also like to use JSON to 
serve as my client side model where changes made to a JSON graph, on the 
client, could be posted back to an action for processing (validation, 
persistence, etc..) on the server.

The basic setup is that my action would get a handle to a graph of 
objects returned by calls to the data layer through Hibernate.  The 
graph would then be serialized to JSON (ugliness of this serialization 
aside) and the resultant JSON representation would be shipped to a JSP.  
Getting the JSON graph to a JSP is easy enough.  I could simply emit the 
JSON data as part of a forward.  In fact, this works great in situations 
where I retrieve data outside of the context of form's round trip.  For 
example, getting data as part of an async Ajax call to an action in 
order to populate a select box. 

The problem I am having is that I find it difficult to wire up an action 
form for complex graphs to achieve auto form population upon form 
submission.  I'd like to be able to wire up my action form in such a way 
that modifications made to a client side JSON representation of the form 
bean (the graph) would be reflected on the server side. 

Has anyone else dealt with this?  Any help is appreciated.

Thanks,

Alejandro


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 1.3, JSON, and Action Forms

Posted by Musachy Barroso <mu...@gmail.com>.
I've been working on a JSON plugin to serialize/deserialize actions to/from
JSON, but it is for Struts 2. You could at least reuse the
serialization/deserialization code:

http://code.google.com/p/jsonplugin/

musachy

On 2/7/07, Alejandro Calbazana <al...@calbazana.com> wrote:
>
> Hello,
>
> I am wondering if anyone has made use of Ajax and SON under Struts 1.3...
>
> I'd like to make use of JSON in my Struts application in order to ease
> the process of data binding Dojo widgets.  I'd also like to use JSON to
> serve as my client side model where changes made to a JSON graph, on the
> client, could be posted back to an action for processing (validation,
> persistence, etc..) on the server.
>
> The basic setup is that my action would get a handle to a graph of
> objects returned by calls to the data layer through Hibernate.  The
> graph would then be serialized to JSON (ugliness of this serialization
> aside) and the resultant JSON representation would be shipped to a JSP.
> Getting the JSON graph to a JSP is easy enough.  I could simply emit the
> JSON data as part of a forward.  In fact, this works great in situations
> where I retrieve data outside of the context of form's round trip.  For
> example, getting data as part of an async Ajax call to an action in
> order to populate a select box.
>
> The problem I am having is that I find it difficult to wire up an action
> form for complex graphs to achieve auto form population upon form
> submission.  I'd like to be able to wire up my action form in such a way
> that modifications made to a client side JSON representation of the form
> bean (the graph) would be reflected on the server side.
>
> Has anyone else dealt with this?  Any help is appreciated.
>
> Thanks,
>
> Alejandro
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd