Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get javascript (jquery) Array from java?

I'm trying to get every value from an 'application' object (in javascript using jquery) which has mostly Strings and booleans properties, but also a List. I want to get it on my server-side, java.

Here what I do to get the Strings and boolean :

Javascript with REST :

requete = clientRestApplication.saveApplication.read(application.id, application);
            requete.done();

application is my object of course. It contains an Array called mails filled with Strings.

@RequestMapping(value = "/enregistrerApplication/id/{id}", method = RequestMethod.GET)
@ResponseBody
public void EnregistrerApplication(@PathVariable Long id, String nom, String acronyme, Integer idWebGD, Boolean estProgressWindows,
                                    Boolean estProgressUnix, Boolean estDelphi, String cheminPatchWin, String cheminPatchUnix,
                                    String cheminOutilsCompileWin, String cheminOutilsCompileUnix,  String serveurCVS, String loginCVS, 
                                    String mdpCVS, boolean versionEncours, ArrayList<String> mails) { ... }

From here I can use every single attributes to do what I want, but can't get my array by any mean...

I'm probably doing something wrong, can somebody help ? Thanks a lot.

like image 501
ToyToy Avatar asked Jul 23 '15 11:07

ToyToy


1 Answers

Make your Java part return JSON. Convert your Jaava Array to JSON: Convert normal Java Array or ArrayList to Json Array in android

And process this JSON from the Javascript/JQuery side.

EDIT Reverse: Get JSON and converts into a Java Array : How to parse a JSON and turn its values into an Array?

like image 65
3pic Avatar answered Oct 17 '22 00:10

3pic