Results 1 to 5 of 5

Thread: send an array of String in an ajax request and get it in JAVA from the server side

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    304

    Default send an array of String in an ajax request and get it in JAVA from the server side

    Hi,

    I try to send several parameters (the number of parameters may vary) in an ajax request and I don't know how to send them and how to get them in JAVA from the server side.

    One solution may be : Is it possible to send an array of String : params: { fieldRefForVisibility: parameters } (where parameters is an array of String) and from the server side get them with the following method : java.lang.String[] getParameterValues(java.lang.String name)

    Thank you in advance for your answers

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    And what is the problem? It already works the way you describe.

  3. #3
    Sencha User
    Join Date
    Jul 2010
    Posts
    304

    Default

    Hi condor and thank you for your answer,

    Usually, when I send parameters in an ajax request I give the name and the value this way
    Code:
    params: { param1: value1, param2: value2 }
    This is OK when I have a determined number of parameters and when I expect only param1 and param2 on the server side
    from the server side I get them in JAVA this way
    Code:
    String param1 = request.getParameter("param1");
    But in my case I would like to send for example this array ["id1;value1", "id2;value2", "id3;value3", ...., "idn;valuen"]
    The problem is that I don't know in advance the number of parameters (that is n) which may vary
    and the ids (id1, id2, ...) and values (value1, value2, ...) may change from one request to another

    So is it possible to send the params this way :
    Code:
    params: { record:  ["id1;value1", "id2;value2", "id3;value3", ...., "idn;valuen"] }
    And may be get the array in JAVA with the following method : java.lang.String[] getParameterValues(java.lang.String name)

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Code:
    params: {
      myParams: ["id1;value1", "id2;value2", "id3;value3", ...., "idn;valuen"]
    }
    Code:
    String[] myParams = request.getParameterValues("myParams");

  5. #5
    Sencha User
    Join Date
    Jul 2010
    Posts
    304

    Default

    Thank you very much condor.

    That is what I was looking for

  6. #6
    Sencha User
    Join Date
    Feb 2017
    Posts
    0

    Default

    Quote Originally Posted by Condor View Post
    Code:
    params: {
      myParams: ["id1;value1", "id2;value2", "id3;value3", ...., "idn;valuen"]
    }
    Code:
    String[] myParams = request.getParameterValues("myParams");
    When i use this the array value being like this in servlet page. [Ljava.lang.String;@6ba98755

    Please suggest me.

Similar Threads

  1. Server side sorting with EXTJS, DWR, JAVA
    By Praveen Adivi in forum Ext 3.x: Help & Discussion
    Replies: 17
    Last Post: 3 Nov 2010, 10:28 AM
  2. How to send an array as a parameter in an Ajax Request?
    By dbassett74 in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 10 Jul 2010, 3:27 PM
  3. Send array from extjs to server
    By treblereel in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 27 May 2010, 2:42 AM
  4. Thoughts on dwr or json for java server side
    By sfwalter in forum Community Discussion
    Replies: 18
    Last Post: 27 Jan 2008, 7:51 AM
  5. Access to grid from the server side Java Code
    By ash9122 in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 3 Jan 2007, 1:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •