I'm glad you got it working 2011/1/7 Jim Talbut <jim.tal...@groupgti.com>: > Brilliant, thanks. > > Jim > > -----Original Message----- > From: Maurizio Cucchiara [mailto:maurizio.cucchi...@gmail.com] > Sent: 06 January 2011 16:51 > To: Struts Users Mailing List > Subject: Re: JSON Property > > Try > <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> > > 2011/1/6 Jim Talbut <jim.tal...@groupgti.com>: >> Ah, sort of. >> Actually WW-3554 stopped me working that one out :) >> >> Now I've moved the JsonPlugin.tld to my own WEB-INF I can make it work, but >> not using the syntax you used. >> >> If I have: >> <%...@taglib prefix="json" uri="/struts-json-tags" %> >> <%...@taglib prefix="c" uri="http://java.sun.com/jstl/core" %> >> <c:out value="${json:serialize(orderLines)}"/> >> >> I get: PWC6236: According to TLD or attribute directive in tag file, >> attribute value does not accept any expressions >> >> But if I just put ${json:serialize(orderLines)} on its own it does output >> the JSON. >> >> I'm new to JSTL, do I have to do something in order to use an OGNL-based >> expression with c:out? >> >> >> Thanks >> >> Jim >> >> -----Original Message----- >> From: Maurizio Cucchiara [mailto:maurizio.cucchi...@gmail.com] >> Sent: 05 January 2011 19:23 >> To: Struts Users Mailing List >> Subject: Re: JSON Property >> >> Did this answer your question? >> https://issues.apache.org/jira/browse/WW-3553 >> >> 2011/1/5 Chris Pratt <thechrispr...@gmail.com>: >>> I'm not sure how to make it work, but it would totally rock if we could make >>> the "encode" attribute of the <s:property> tag extensible by plug-in's. >>> That way the standard tag could possibly supply encode="html" & encode="js" >>> and the JSON plug-in could add encode="json" and other plug-ins could extend >>> it in ways they need. Just a wild thought. >>> (*Chris*) >>> >>> On Wed, Jan 5, 2011 at 1:22 AM, Steven Yang <kenshin...@gmail.com> wrote: >>> >>>> I think its "bundled" with S2 but as a separate jar, so dont get mistaken. >>>> >>>> i am a bit reluctant to share my code, which is old and bad, not that >>>> because i am cheap or anything, its because there are better and >>>> well-thought code out there (as in JSON plug in) and my code has lots of >>>> things tied to my project (bad design......). >>>> >>>> and you know what i just checked back on my tag code. I dont think i am >>>> doing anything much different from what your doing. I siimply copied the >>>> s:property tag code and replaced the output part of the code. >>>> >>>> here is the part i replaced.....(my tag mimics the "property" tag) >>>> try { >>>> if (actualValue != null) { >>>> if (!(actualValue instanceof String)) { //if String then >>>> treated its as if in JSON format >>>> actualValue = JSONUtil.toJSON(actualValue); >>>> } >>>> writer.write(actualValue.toString()); >>>> } >>>> else if (defaultValue != null) { >>>> writer.write(defaultValue); >>>> } >>>> } >>>> catch (IOException e) { >>>> LoggerUtil.BASE_LOGGER.info("error ocurred while writing json: >>>> " >>>> + actualValue, e); >>>> } >>>> >>>> On Wed, Jan 5, 2011 at 4:59 PM, Maurizio Cucchiara < >>>> maurizio.cucchi...@gmail.com> wrote: >>>> >>>> > The json plugin is bundled with S2, because previously was on google >>>> > code, and one had to download separately >>>> > >>>> > 2011/1/5 Jim Talbut <jim.tal...@groupgti.com>: >>>> > > You are both right. >>>> > > >>>> > > The tag that I'm using at the moment (which isn't fully tested at all, >>>> > got some data issues to sort out first) is just the property tag with the >>>> > following modification: >>>> > > Object objectValue = getStack().findValue(value, >>>> > throwExceptionOnELFailure); >>>> > > try { >>>> > > actualValue = JSONUtil.serialize( objectValue ); >>>> > > } catch( JSONException ex ) { >>>> > > LOG.error("Could not convert {} to a JSON serialized value: >>>> > {}", objectValue, ex); >>>> > > } >>>> > > >>>> > > Given that I'm using a utility function from the JSON plugin it does >>>> seem >>>> > to make sense to have that plugin provide this tag. >>>> > > >>>> > > I've filed a feature request against it ( >>>> > https://issues.apache.org/jira/browse/WW-3553), but it doesn't seem to >>>> be >>>> > a very active project. >>>> > > I'm also confused by the fact that this page >>>> > https://cwiki.apache.org/S2PLUGINS/json-plugin.html says that the plugin >>>> > is bundled with Struts, although the JSONUtil class is not in >>>> struts-core. >>>> > > >>>> > > Steven, if you have a more complete and tested tag could you be >>>> persuaded >>>> > to add it to the plugin, or just add what you've got to the bug? >>>> > > >>>> > > Jim >>>> > > >>>> > > >>>> > > -----Original Message----- >>>> > > From: Chris Pratt [mailto:thechrispr...@gmail.com] >>>> > > Sent: 05 January 2011 02:32 >>>> > > To: Struts Users Mailing List >>>> > > Subject: Re: JSON Property >>>> > > >>>> > > The plugin has several things it can do, from parsing JSON to >>>> generating >>>> > > JSON results. And yes, the default is to JSON up the whole Action, but >>>> > you >>>> > > can have it objectify any object you want. And it is the collection >>>> > point >>>> > > for JSON support in Struts 2. >>>> > > (*Chris*) >>>> > > >>>> > > On Tue, Jan 4, 2011 at 6:12 PM, Steven Yang <kenshin...@gmail.com> >>>> > wrote: >>>> > > >>>> > >> I might be wrong here. As I remember JSON Plugin turns the whole >>>> action >>>> > >> into >>>> > >> one single JSON object. I dont believe its what Jim wants, but most >>>> > >> definitely there must be something Jim can use in the Plugin to >>>> > transform >>>> > >> his Java Objects to JSON. >>>> > >> >>>> > >> On Wed, Jan 5, 2011 at 2:47 AM, Chris Pratt <thechrispr...@gmail.com> >>>> > >> wrote: >>>> > >> >>>> > >> > The "obvious" place to me would seem to be the Struts 2 JSON >>>> Plug-in, >>>> > >> since >>>> > >> > it handles all the other JSON duties for Struts 2. >>>> > >> > (*Chris*) >>>> > >> > >>>> > >> > On Tue, Jan 4, 2011 at 10:32 AM, Jim Talbut < >>>> jim.tal...@groupgti.com> >>>> > >> > wrote: >>>> > >> > >>>> > >> > > I could do that (as Aaron Brown suggested on Monday) but I don't >>>> > >> already >>>> > >> > > have actions that spit out the right JSON. >>>> > >> > > Creating more actions would be more work than creating JSON >>>> getters. >>>> > >> > > Creating either actions or special getters also seems wrong to me >>>> - >>>> > >> it's >>>> > >> > > the JSP that needs JSON and it should only be the JSP that knows >>>> > that >>>> > >> it >>>> > >> > > needs JSON. >>>> > >> > > Obviously if one is dealing with AJAX one has no choice but to >>>> have >>>> > >> JSON >>>> > >> > > actions, but I'm not. >>>> > >> > > >>>> > >> > > I've now written a JSON tag, but given that Steven Yang and I have >>>> > now >>>> > >> > > written something to do the same job it seems to me that there >>>> ought >>>> > to >>>> > >> > be >>>> > >> > > some common entity for providing it (i.e. I think it should be in >>>> > >> > > struts-json-tags). >>>> > >> > > >>>> > >> > > Jim >>>> > >> > > >>>> > >> > > -----Original Message----- >>>> > >> > > From: Chris Pratt [mailto:thechrispr...@gmail.com] >>>> > >> > > Sent: 04 January 2011 15:54 >>>> > >> > > To: Struts Users Mailing List >>>> > >> > > Subject: Re: JSON Property >>>> > >> > > >>>> > >> > > You might also need the executeResult="true" attribute on the >>>> > >> <s:action> >>>> > >> > > tag. >>>> > >> > > (*Chris*) >>>> > >> > > >>>> > >> > > On Tue, Jan 4, 2011 at 7:06 AM, Biesbrock, Kevin >>>> > >> > > <biesbrock.ke...@aoins.com>wrote: >>>> > >> > > >>>> > >> > > > > I don't want to use a separate roundtrip for loading the >>>> jqGrid >>>> > for >>>> > >> > > > two reasons: >>>> > >> > > > > 1. I want to handle the contents of the grid, and additional >>>> > >> fields, >>>> > >> > > > in a single transaction. >>>> > >> > > > > 2. It's inefficient and unnecessary. >>>> > >> > > > > Obviously the first is the more important :) >>>> > >> > > > >>>> > >> > > > >>>> > >> > > > I think you could do something like this in your jsp: >>>> > >> > > > >>>> > >> > > > <input type="hidden" name="jgrid-json-data" value="<s:action >>>> > >> > > > name="myJsonAction" namespace="/json"/>"/> >>>> > >> > > > >>>> > >> > > > This would allow you to use the already-in-place json result >>>> type >>>> > and >>>> > >> > > > save you a lot of extra work. >>>> > >> > > > >>>> > >> > > > >>>> > >> > > > -Beez >>>> > >> > > > >>>> > >> > > > >>>> > >> > > > >>>> > --------------------------------------------------------------------- >>>> > >> > > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>> > >> > > > For additional commands, e-mail: user-h...@struts.apache.org >>>> > >> > > > >>>> > >> > > > >>>> > >> > > >>>> > >> > > >>>> > --------------------------------------------------------------------- >>>> > >> > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>> > >> > > For additional commands, e-mail: user-h...@struts.apache.org >>>> > >> > > >>>> > >> > > >>>> > >> > >>>> > >> >>>> > > >>>> > > --------------------------------------------------------------------- >>>> > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>> > > For additional commands, e-mail: user-h...@struts.apache.org >>>> > > >>>> > > >>>> > >>>> > >>>> > >>>> > -- >>>> > Maurizio Cucchiara >>>> > >>>> > --------------------------------------------------------------------- >>>> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>> > For additional commands, e-mail: user-h...@struts.apache.org >>>> > >>>> > >>>> >>> >> >> >> >> -- >> Maurizio Cucchiara >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > > > > -- > Maurizio Cucchiara > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
-- Maurizio Cucchiara --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org