Shank Kolin Shank Kolin - 1 month ago 6
Ajax Question

Stripes and Jquery and Ajax for dynamic dropdowns

I am using Stripes for the web tier. I want to include two dropdowns where the list of items in the second dropdown is dependent on the value chosen in the first.

Pretty straightforward Ajax you say. I can't find a single example of doing this. The examples on Stripes site are all trivial, like updating a label. I read, that the JSON returned by Stripes is funky & not straightforward for jQuery to handle. How can I do that? An example would be appreciated!

Answer

You could use Google Gson (https://code.google.com/p/google-gson/) For example:

import com.google.gson.Gson;

public Resolution autocomplete() {

    List<String> opts = new ArrayList<String>();

    ...

    String json = new Gson().toJson(opts);
    return new StreamingResolution("application/json",json);
}