Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: Struts 2 & JSON

Musachy Barroso

2007-01-08

Replies:

The autocmpleter needs to get the data in some format, that format is
JSON, the response needs to be something like:

[
 ["Text1", "Key1"],
 ["Text2", "Key2"],
]

Remember that what you return from "execute" is not the response, it is
the result, like "success" or "input", so you can't return the json
object from the action. What you can do, if you don't want to use
freemarker, velocity or jsp to build the json object, is to write
directly to the outpustream. Soon we will have a "json" result type,
that will take care of serializing the action to a json string for you.

hope that helps
musachy

Andr? Faria wrote:
> What is necessary to write a JSON response in struts to use with a
> Autocomplete tag?
>
> example:
>
> public class JSONListAction {
>   public String execute {
>     ???????????????? return JSON object!
>   }
> }
>
> <s:url id="json" value="/JSONList.action" />
> <s:autocompleter theme="ajax" href="%{json}" autoComplete="false"/>
>
>
>
> Thank's
> Andr? Faria
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.