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]

Reply via email to