You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by wolverine my <wo...@gmail.com> on 2007/04/26 05:07:25 UTC

[S2] Autocompleter and JSON list

Hi!

Based on Struts showcase, I have tried the below AJAX tags:

<s:url id="json" value="/JSONList.action" />
<s:autocompleter theme="ajax" href="%{json}" autoComplete="false"/>


and the JSONList action simply return the hardcoded contents of
>/ajax/JSONList.js:

[
     ["Alabama","AL"],
     ["Alaska","AK"],
     ...
     ["Wyoming","WY"]
]


Now, to return the list dynamically (e.g. read from the database), I
will have to retrieve the values from the database, then format the
values into a string in JSON format and store it in the session before
it can be referrenced in the autocompleter tag?

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


Re: [S2] Autocompleter and JSON list

Posted by Musachy Barroso <mu...@gmail.com>.
Yes, you might want to use the JSON plugin:

http://cwiki.apache.org/S2PLUGINS/json-plugin.html

musachy

On 4/26/07, wolverine my <wo...@gmail.com> wrote:
>
> In my action class, what is the way to format my the values into JSON
> string?
> Do I need to construct the string in JSON format?
>
>
> On 4/26/07, Dave Newton <ne...@yahoo.com> wrote:
> > --- wolverine my <wo...@gmail.com> wrote:
> > > Now, to return the list dynamically (e.g. read from
> > > the database), I will have to retrieve the values
> > > from the database,
> >
> > Yeah.
> >
> > > [...] store it in the session
> >
> > You don't need to store it in session.
> >
> > d.
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> 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

Re: [S2] Autocompleter and JSON list

Posted by wolverine my <wo...@gmail.com>.
In my action class, what is the way to format my the values into JSON string?
Do I need to construct the string in JSON format?


On 4/26/07, Dave Newton <ne...@yahoo.com> wrote:
> --- wolverine my <wo...@gmail.com> wrote:
> > Now, to return the list dynamically (e.g. read from
> > the database), I will have to retrieve the values
> > from the database,
>
> Yeah.
>
> > [...] store it in the session
>
> You don't need to store it in session.
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: [S2] Autocompleter and JSON list

Posted by Dave Newton <ne...@yahoo.com>.
--- wolverine my <wo...@gmail.com> wrote:
> Now, to return the list dynamically (e.g. read from
> the database), I will have to retrieve the values 
> from the database,

Yeah.

> [...] store it in the session 

You don't need to store it in session.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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