struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Yang <>
Subject Re: JSON Property
Date Tue, 04 Jan 2011 01:48:27 GMT
well for me I do have an custom tag
the tag converts any entity into JSON, so for example i have

List<MyEntity> myEntities;

in my JSP i can do <s:iterator ....> or output as Javascript array <sx:json
value="myEntities"/> without action knowing what the output will be

and in the tag i have my own formatting rule for JSON. of course i am sure
there are tones JAVA -> JSON converter out there you can use.

this way i have more control over the output  (possibly more bug lol)

thats the way i do it......

On Mon, Jan 3, 2011 at 9:23 PM, Jim Talbut <> wrote:

> Yes, I thought about that, but it's even more work than creating a custom
> "get" method and equally unreusable.
> I've done this often enough that I think a custom tag is justified.
> The reason I keep wanting to do it is to set up jqGrid data so that I can
> have a parent record with children (the children being in the jqGrid and set
> via JSON) submitted as a single entity (I typically put the JSON data into a
> hidden field and then update it in the submit, but there are also other uses
> for the JSON data, such as selection lists, that don't get updated).
> Jim
> ________________________________________
> From: Aaron Brown []
> Sent: 03 January 2011 13:11
> To: Struts Users Mailing List
> Subject: Re: JSON Property
> Have you considered using an include? You can call a json-result-type
> action
> with it or switch to some other fragment result if needed. Perhaps it's
> quick and dirty compared with creating a custom tag but it seems to me it
> would be a lot easier to implement.
> - Aaron
>  On Jan 3, 2011 6:50 AM, "Jim Talbut" <> wrote:
> > Hi,
> >
> > I keep needing to put the JSON equivalent of an expression into a JSP
> page
> to be used by client side javascript.
> > This is done during the evaluation of the JSP, it's not AJAX.
> >
> > At the moment I'm doing it by creating a special "get" method on the
> action, but that's not nice - the action shouldn't need to know that I want
> the representation in JSON.
> >
> > I've started looking at creating an alternative tag to do the job, but it
> would be pretty much a complete copy of the property tag, but with an
> additional "escape"-type property to specify that the result should be
> > It's slightly more complicated than that because the normal escapes
> should
> be applied afterwards too.
> >
> > Question: Is this something that should be implemented in the base
> property tag as an enhancement to struts itself, or should I just copy the
> property tag and get on with my life?
> >
> > Thanks
> > Jim
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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