Musachy, This is the actual response from the action when I invoke it from the browser:
"{\"questions\":{\"420\":\"Is your Java Application a ME, SE or EE application?\",\"440\":\"If your Java Application is an SE application does it use Java Web Start?\",\"450\":\"If your Java Application is a Java Web Application, list the application server used for production\",\"490\":\"List any Java Web Services Technologies Used\",\"500\":\"List any Java Web Application Technologies Used for presentation\",\"510\":\"List any Java EE Technologies used in your application\"}}" I am building the JSON string and returning it from the action... private static final Character QUOTE= '"'; private static final String DELIM= ":"; private static final String COMMA=","; private static final String OPEN_BRACE="{"; private static final String CLOSE_BRACE="}"; StrinBuffer sb= new StringBuffer(); StringBuffer sb= new StringBuffer(); sb.append(OPEN_BRACE).append(QUOTE).append("questions").append(QUOTE); sb.append(DELIM).append(OPEN_BRACE); for (Question question : list) { sb.append(QUOTE).append(question.getId().toString()).append(QUOTE).appen d(DELIM).append(QUOTE).append(question.getText()).append(QUOTE).append(C OMMA); } ... The String actually looks like this before its serialized by the json result: {"questions":{"420":"Is your Java Application a ME, SE or EE application?","440":"If your Java Application is an SE application does it use Java Web Start?","450":"If your Java Application is a Java Web Application, list the application server used for production","490":"List any Java Web Services Technologies Used","500":"List any Java Web Application Technologies Used for presentation","510":"List any Java EE Technologies used in your application"}} -----Original Message----- From: Musachy Barroso [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 05, 2008 1:20 PM To: Struts Users Mailing List Subject: Re: AjaxTag 1.3 support? Oh I am sorry about that! (doh) Do you see the quoutes escaped in firebug or something? As far as I remember the plugin doesnt escape the quoutes. If you put the url in your browser you should see the generated json as it actually is. musachy On Feb 5, 2008 2:12 PM, Griffith, Michael * <[EMAIL PROTECTED]> wrote: > Musachy, > > Huh? That can't be right... > > First of all, the document says it wraps the JSON result in /* ... */ > comments, it doesn't say anything about escaping quotes. > > Second, the default value is false ;-) Adding this to the result > configuration did nothing to my result. This seems like a bug. > > MG > > -----Original Message----- > From: Musachy Barroso [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, February 05, 2008 12:14 PM > To: Struts Users Mailing List > Subject: Re: AjaxTag 1.3 support? > > add: > > <param name="wrapWithComments">false</param> > > to the result. See the section "Wrap with Comments" here: > > http://cwiki.apache.org/S2PLUGINS/json-plugin.html > > musachy > > On Feb 5, 2008 12:58 PM, Griffith, Michael * > <[EMAIL PROTECTED]> wrote: > > Musachy, > > > > I've looked over the documentation, and looked in the JSONWriter class > > -- and it is not obvious to me how to configure this plugin setting. > > How is it done? > > > > MG > > > > -----Original Message----- > > From: Musachy Barroso [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, February 05, 2008 11:23 AM > > To: Struts Users Mailing List > > > > Subject: Re: AjaxTag 1.3 support? > > > > Don't give up so easily :). That is just a setting on the json plugin > > to prevent cross site scripting, and can be disabled. > > > > musachy > > > > On Feb 5, 2008 11:27 AM, Griffith, Michael * > > <[EMAIL PROTECTED]> wrote: > > > Well, to answer my own question -- the answer is no. The JSON result > > > serialization process escapes quotation marks, so my response that > > > looked like this before serialization: > > > > > > {"questions":{"420":"Is your Java Application a ME, SE or EE > > > application?","440":"If your Java Application is an SE application > > does > > > it use Java Web Start?","450":"If your Java Application is a Java > Web > > > Application, list the application server used for > > > production","490":"List any Java Web Services Technologies > > > Used","500":"List any Java Web Application Technologies Used for > > > presentation","510":"List any Java EE Technologies used in your > > > application"}} > > > > > > Looks like this after serialization: > > > > > > "{\"questions\":{\"420\":\"Is your Java Application a ME, SE or EE > > > application?\",\"440\":\"If your Java Application is an SE > application > > > does it use Java Web Start?\",\"450\":\"If your Java Application is > a > > > Java Web Application, list the application server used for > > > production\",\"490\":\"List any Java Web Services Technologies > > > Used\",\"500\":\"List any Java Web Application Technologies Used for > > > presentation\",\"510\":\"List any Java EE Technologies used in your > > > application\"}}" > > > > > > Making it unrecognizable to the autocompleter. This is pretty > > > frustrating to me. Maybe I am expecting this to do something that it > > was > > > never designed to do. My end goal was to be able to evaluate the ID > of > > > the question that the user selected from the autocompleter. > > > > > > I'm giving up this path and looking elsewhere. Thanks to everyone > > that > > > replied to my question and tried to help me. > > > > > > MG > > > > > > > > > -----Original Message----- > > > From: Griffith, Michael * [mailto:[EMAIL PROTECTED] > > > Sent: Tuesday, February 05, 2008 8:32 AM > > > To: Struts Users Mailing List > > > Subject: RE: AjaxTag 1.3 support? > > > > > > Musachy, > > > > > > I can't seem to create the right blend of Entity objects/list/maps > to > > > allow the JSON plug in to serialize this response for me. If I > create > > > the string below using a loop, can I return it from the JSON plug in > > > without the plug in doing anything further to it? > > > > > > In other words, does the plug in look at what it is trying to > > serialize > > > and say, "Hey this is already valid JSON, I don't need to do > anything > > to > > > it..." or will it try to add additional info to the string returned? > > > > > > I'm guessing the shortest path for me is to just create the string > in > > my > > > own serialization loop, but I don't want to confuse the plug in -- > if > > > that makes any sense. > > > > > > MG > > > > > > -----Original Message----- > > > From: Musachy Barroso [mailto:[EMAIL PROTECTED] > > > Sent: Monday, February 04, 2008 6:30 PM > > > To: Struts Users Mailing List > > > Subject: Re: AjaxTag 1.3 support? > > > > > > Right on. > > > > > > On Feb 4, 2008 6:45 PM, Griffith, Michael * > > > <[EMAIL PROTECTED]> wrote: > > > > Dave, > > > > > > > > I think the bigger problem is the JSON that is returned, while it > > may > > > be > > > > valid, it not in the right structure expected. I should be > > generating > > > > JSON like this: > > > > > > > > {"questions":{"420":"Is your Java Application a ME, SE or EE > > > > application?","440":"If your Java Application is an SE application > > > does > > > > it use Java Web Start?"}} > > > > > > > > The [] brackets seem to be ignored by the parser. > > > > > > > > -----Original Message----- > > > > From: Dave Newton [mailto:[EMAIL PROTECTED] > > > > Sent: Monday, February 04, 2008 5:34 PM > > > > To: Struts Users Mailing List > > > > Subject: RE: AjaxTag 1.3 support? > > > > > > > > ... > > > > > > > > > > > > That's probably an issue. > > > > > > > > --- "Griffith, Michael *" <[EMAIL PROTECTED]> wrote: > > > > > Yea, I think so -- I copied and pasted this from the log > > > > file/console... > > > > > > > > > > From: Dave Newton [mailto:[EMAIL PROTECTED] > > > > > > > > > > Is it generating those brackets around your JSON? > > > > > > > > > > --- "Griffith, Michael *" <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > Musachy, > > > > > > > > > > > > Thanks for your many replies... Does this JSON look like the > > right > > > > > > format? As far as I can tell, it matches your snippet below -- > > but > > > I > > > > > get > > > > > > the same dojo parting error. > > > > > > > > > > > > [{"questions":{"420":"Is your Java Application a ME, SE or EE > > > > > > application?"}},{"questions":{"440":"If your Java Application > is > > > an > > > > SE > > > > > > application does it use Java Web > > Start?"}},{"questions":{"450":"If > > > > > your > > > > > > Java Application is a Java Web Application, list the > application > > > > > server > > > > > > used for production"}}] > > > > > > > > > > > > -----Original Message----- > > > > > > From: Musachy Barroso [mailto:[EMAIL PROTECTED] > > > > > > Sent: Monday, February 04, 2008 3:52 PM > > > > > > To: Struts Users Mailing List > > > > > > Subject: Re: AjaxTag 1.3 support? > > > > > > > > > > > > The rule to use a map (simplest one) was added on 2.1, on > 2.0.x > > > the > > > > > > easiest way to generate the json is to have an object with a > map > > > > field > > > > > > that matches the name of "dataFieldName" in the autocompleter > > tag: > > > > > > > > > > > > class QuestionJson { > > > > > > private Map questions; > > > > > > .... > > > > > > } > > > > > > > > > > > > public QuestionJson getQuestionJson() { > > > > > > Question q= ... [from my list] > > > > > > Map m = new HaswhMap(); > > > > > > m.put("Key1", q.getQuestion1()); > > > > > > m.put("Key2", q.getQuestion2()); > > > > > > return new QuestionJson(m); > > > > > > } > > > > > > > > > > > > <s:autocompleter ... dataFieldName="questions" ../> > > > > > > > > > > > > that will generate something like: > > > > > > > > > > > > { > > > > > > "questions": { > > > > > > "Key1" : "Question 1", > > > > > > "Key2" : "Question 2", > > > > > > } > > > > > > } > > > > > > > > > > > > //that's the idea, but I typed out of what I remember which is > > > often > > > > > not > > > > > > good :) > > > > > > > > > > > > musachy > > > > > > > > > > > > On Feb 4, 2008 4:34 PM, Griffith, Michael * > > > > > > <[EMAIL PROTECTED]> wrote: > > > > > > > Musachy, > > > > > > > > > > > > > > I'm still not getting it... > > > > > > > I am now serializing a list of maps with the entity id and > > text > > > I > > > > > > > want... > > > > > > > > > > > > > > Map<String,String> m= new HashMap<String,String>(); > > > > > > > Question q= ... [from my list] > > > > > > > m.put("id", q.getId().toString()); > > > > > > > m.put("text", q.getText()); > > > > > > > newList.add(m); > > > > > > > > > > > > > > And my JSON result looks: > > > > > > > > > > > > > > [JSON][{"text":"Is your Java Application a ME, SE or EE > > > > > > > application?","id":"420"},{"text":"If your Java Application > is > > > an > > > > SE > > > > > > > application does it use Java Web > > Start?","id":"440"},{"text":"If > > > > > your > > > > > > > Java Application is a Java Web Application, list the > > application > > > > > > server > > > > > > > used for production","id":"450"},{"text":"List any Java Web > > > > Services > > > > > > > Technologies Used","id":"490"},{"text":"List any Java Web > > > > > Application > > > > > > > Technologies Used for > presentation","id":"500"},{"text":"List > > > any > > > > > Java > > > > > > > EE Technologies used in your application","id":"510"}] > > > > > > > > > > > > > > I added the @JSON annotation as such: > > > > > > > > > > > > > > @JSON(name="question") > > > > > > > public List<Map<String,String>> getNewList(){ > > > > > > > return newList; > > > > > > > } > > > > > > > > > > > > > > But it appears to be ignored. > > > > > > > > > > > > > > MG > > > > > > > > > > > > > > -----Original Message----- > > > > > > > From: Musachy Barroso [mailto:[EMAIL PROTECTED] > > > > > > > > > > > > > > Sent: Monday, February 04, 2008 2:53 PM > > > > > > > To: Struts Users Mailing List > > > > > > > Subject: Re: AjaxTag 1.3 support? > > > > > > > > > > > > > > Take a look here: > > > > > > > > > > > > > > http://cwiki.apache.org/S2PLUGINS/json-plugin.html > > > > > > > > > > > > > > musachy > > > > > > > > > > > > > > On Feb 4, 2008 3:43 PM, Griffith, Michael * > > > > > > > <[EMAIL PROTECTED]> wrote: > > > > > > > > So, if you have an array of Entity objects, in my case > > > question: > > > > > > > > > > > > > > > > How can I produce? > > > > > > > > { > > > > > > > > "question" : [ > > > > > > > > ["1","question 1 text..."], > > > > > > > > ["2","question 2 text..."] > > > > > > > > > > > > > > > > ] > > > > > > > > } > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: Musachy Barroso [mailto:[EMAIL PROTECTED] > > > > > > > > Sent: Monday, February 04, 2008 2:37 PM > > > > > > > > To: Struts Users Mailing List > > > > > > > > Subject: Re: AjaxTag 1.3 support? > > > > > > > > > > > > > > > > yes, but the output will depend on what you feed the JSON > > > > result. > > > > > > > > > > > > > > > > musachy > > > > > > > > > > > > > > > > On Feb 4, 2008 3:20 PM, Griffith, Michael * > > > > > > > > <[EMAIL PROTECTED]> wrote: > > > > > > > > > Musachy, > > > > > > > > > > > > > > > > > > I must have missed your point. Isn't the idea of using > the > > > > JSON > > > > > > > > plug-in > > > > > > > > > so you don't have to iterate and create the list? If I > > have > > > an > > > > > > array > > > > > > > > or > > > > > > > > > Entity objects or maps, isn't there a way that the > plug-in > > > > will > > > > > > > create > > > > > > > > > the JSON specified below? > > > > > > > > > > > > > > > > > > MG > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > > From: Musachy Barroso [mailto:[EMAIL PROTECTED] > > > > > > > > > Sent: Monday, February 04, 2008 1:56 PM > > > > > > > > > To: Struts Users Mailing List > > > > > > > > > Subject: Re: AjaxTag 1.3 support? > > > > > > > > > > > > > > > > > > > > > > > > > > > to use the dataFIeldName, you have to return something > > like: > > > > > > > > > > > > > > > > > > { > > > > > > > > > "state" : [ > > > > > > > > > ["Alabama","AL"], > > > > > > > > > ["Alaska","AK"] > > > > > > > > > ] > > > > > > > > > } > > > > > > > > > > > > > > > > > > if you are using 2.1 check this link: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://cwiki.apache.org/WW/ajax-and-javascript-recipes.html#AjaxandJavaS > > > > > > > > > criptRecipes-Autocompleter > > > > > > > > > > > > > > > > > > otherwise just an array of arrays should do: > > > > > > > > > > > > > > > > > > [ > > > > > > > > > ["Alabama", "AL"], > > > > > > > > > ["Alaska", "AK"] > > > > > > > > > ] > > > > > > > > > > > > > > > > > > musachy > > > > > > > > > > > > > > > > > > On Feb 4, 2008 2:46 PM, Griffith, Michael * > > > > > > > > > <[EMAIL PROTECTED]> wrote: > > > > > > > > > > Musachy > > > > > > > > > > > > > > > > > > > > Here is the autocompleter tag and the JSON returned... > > > > > > > > > > > > > > > > > > > === message truncated === > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > -- > > > "Hey you! Would you help me to carry the stone?" Pink Floyd > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > -- > > "Hey you! Would you help me to carry the stone?" Pink Floyd > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > "Hey you! Would you help me to carry the stone?" Pink Floyd > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- "Hey you! Would you help me to carry the stone?" Pink Floyd --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]