Pass the list of checked values to controller by Bean object?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















Trying to pass the list of selected subjects to Controller, but the bean is not receiving the list of subjects.



Here's the code that I'm trying:



$("#submitCreateStudent").click(function() {
var selSubjectIds = new Array();
$('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
if (selSubjectIds.length < 1)
selSubjectIds.push($(this).attr('data-record-key') + '$');
else
selSubjectIds += $(this).attr('data-record-key') + '$';

);

if (validateCreateStudentForm())

var data = new FormData();
data.append('firstName', $("#firstNameInCreateStudent").val());
data.append('lastName', $("#lastNameInCreateStudent").val());
data.append('address', $("#studentAddressInCreateStudent").val());
data.append('collegeName', $("#studentCollegeNameInCreateStudent").val());
data.append('phoneNumber', $("#phoneNumberInCreateStudent").val());
data.append('email', $("#emailInCreateStudent").val());
data.append('studentDepartment', $("#departmentInCreateStudent").val());
data.append('studentBranch', $("#branchInCreateStudent").val());
data.append('DateOfBirth', $("#dobInCreateStudent").val());
data.append('DateOfReport', $("#dorInCreateStudent").val());
data.append('loginUserName', $("#studentUserNameInCreateStudent").val());
data.append('loginPassword', $("#passwordInCreateStudent").val());
data.append('studentSubjects', selSubjectIds);

// data.append('skipInitialTraining', skipInitialTraining);

$("#maskingId").mask("Saving...");

$.ajax(
url: "AddStudent.do",
data: data,
//
//Remaining code goes here.
);
);


All the details are coming to controller class except for the list of subjects which are selected check boxes.










share|improve this question
























  • To shorten how about using $("form").on("submit") and $(this).serialize()

    – mplungjan
    Nov 15 '18 at 7:46











  • understood. but will that solve problem?

    – Shaik Bajivali
    Nov 15 '18 at 7:50











  • Simplification is always good. Any errors in console or app log?

    – mplungjan
    Nov 15 '18 at 8:00











  • No error messages in console

    – Shaik Bajivali
    Nov 15 '18 at 8:32











  • it just need to store the elements in the jtable in to array and append it to the data field.

    – Shaik Bajivali
    Nov 15 '18 at 8:33

















2















Trying to pass the list of selected subjects to Controller, but the bean is not receiving the list of subjects.



Here's the code that I'm trying:



$("#submitCreateStudent").click(function() {
var selSubjectIds = new Array();
$('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
if (selSubjectIds.length < 1)
selSubjectIds.push($(this).attr('data-record-key') + '$');
else
selSubjectIds += $(this).attr('data-record-key') + '$';

);

if (validateCreateStudentForm())

var data = new FormData();
data.append('firstName', $("#firstNameInCreateStudent").val());
data.append('lastName', $("#lastNameInCreateStudent").val());
data.append('address', $("#studentAddressInCreateStudent").val());
data.append('collegeName', $("#studentCollegeNameInCreateStudent").val());
data.append('phoneNumber', $("#phoneNumberInCreateStudent").val());
data.append('email', $("#emailInCreateStudent").val());
data.append('studentDepartment', $("#departmentInCreateStudent").val());
data.append('studentBranch', $("#branchInCreateStudent").val());
data.append('DateOfBirth', $("#dobInCreateStudent").val());
data.append('DateOfReport', $("#dorInCreateStudent").val());
data.append('loginUserName', $("#studentUserNameInCreateStudent").val());
data.append('loginPassword', $("#passwordInCreateStudent").val());
data.append('studentSubjects', selSubjectIds);

// data.append('skipInitialTraining', skipInitialTraining);

$("#maskingId").mask("Saving...");

$.ajax(
url: "AddStudent.do",
data: data,
//
//Remaining code goes here.
);
);


All the details are coming to controller class except for the list of subjects which are selected check boxes.










share|improve this question
























  • To shorten how about using $("form").on("submit") and $(this).serialize()

    – mplungjan
    Nov 15 '18 at 7:46











  • understood. but will that solve problem?

    – Shaik Bajivali
    Nov 15 '18 at 7:50











  • Simplification is always good. Any errors in console or app log?

    – mplungjan
    Nov 15 '18 at 8:00











  • No error messages in console

    – Shaik Bajivali
    Nov 15 '18 at 8:32











  • it just need to store the elements in the jtable in to array and append it to the data field.

    – Shaik Bajivali
    Nov 15 '18 at 8:33













2












2








2








Trying to pass the list of selected subjects to Controller, but the bean is not receiving the list of subjects.



Here's the code that I'm trying:



$("#submitCreateStudent").click(function() {
var selSubjectIds = new Array();
$('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
if (selSubjectIds.length < 1)
selSubjectIds.push($(this).attr('data-record-key') + '$');
else
selSubjectIds += $(this).attr('data-record-key') + '$';

);

if (validateCreateStudentForm())

var data = new FormData();
data.append('firstName', $("#firstNameInCreateStudent").val());
data.append('lastName', $("#lastNameInCreateStudent").val());
data.append('address', $("#studentAddressInCreateStudent").val());
data.append('collegeName', $("#studentCollegeNameInCreateStudent").val());
data.append('phoneNumber', $("#phoneNumberInCreateStudent").val());
data.append('email', $("#emailInCreateStudent").val());
data.append('studentDepartment', $("#departmentInCreateStudent").val());
data.append('studentBranch', $("#branchInCreateStudent").val());
data.append('DateOfBirth', $("#dobInCreateStudent").val());
data.append('DateOfReport', $("#dorInCreateStudent").val());
data.append('loginUserName', $("#studentUserNameInCreateStudent").val());
data.append('loginPassword', $("#passwordInCreateStudent").val());
data.append('studentSubjects', selSubjectIds);

// data.append('skipInitialTraining', skipInitialTraining);

$("#maskingId").mask("Saving...");

$.ajax(
url: "AddStudent.do",
data: data,
//
//Remaining code goes here.
);
);


All the details are coming to controller class except for the list of subjects which are selected check boxes.










share|improve this question
















Trying to pass the list of selected subjects to Controller, but the bean is not receiving the list of subjects.



Here's the code that I'm trying:



$("#submitCreateStudent").click(function() {
var selSubjectIds = new Array();
$('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
if (selSubjectIds.length < 1)
selSubjectIds.push($(this).attr('data-record-key') + '$');
else
selSubjectIds += $(this).attr('data-record-key') + '$';

);

if (validateCreateStudentForm())

var data = new FormData();
data.append('firstName', $("#firstNameInCreateStudent").val());
data.append('lastName', $("#lastNameInCreateStudent").val());
data.append('address', $("#studentAddressInCreateStudent").val());
data.append('collegeName', $("#studentCollegeNameInCreateStudent").val());
data.append('phoneNumber', $("#phoneNumberInCreateStudent").val());
data.append('email', $("#emailInCreateStudent").val());
data.append('studentDepartment', $("#departmentInCreateStudent").val());
data.append('studentBranch', $("#branchInCreateStudent").val());
data.append('DateOfBirth', $("#dobInCreateStudent").val());
data.append('DateOfReport', $("#dorInCreateStudent").val());
data.append('loginUserName', $("#studentUserNameInCreateStudent").val());
data.append('loginPassword', $("#passwordInCreateStudent").val());
data.append('studentSubjects', selSubjectIds);

// data.append('skipInitialTraining', skipInitialTraining);

$("#maskingId").mask("Saving...");

$.ajax(
url: "AddStudent.do",
data: data,
//
//Remaining code goes here.
);
);


All the details are coming to controller class except for the list of subjects which are selected check boxes.







javascript jquery spring-mvc jquery-ui






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 7:45









mplungjan

90.1k22127184




90.1k22127184










asked Nov 15 '18 at 7:30









Shaik BajivaliShaik Bajivali

368




368












  • To shorten how about using $("form").on("submit") and $(this).serialize()

    – mplungjan
    Nov 15 '18 at 7:46











  • understood. but will that solve problem?

    – Shaik Bajivali
    Nov 15 '18 at 7:50











  • Simplification is always good. Any errors in console or app log?

    – mplungjan
    Nov 15 '18 at 8:00











  • No error messages in console

    – Shaik Bajivali
    Nov 15 '18 at 8:32











  • it just need to store the elements in the jtable in to array and append it to the data field.

    – Shaik Bajivali
    Nov 15 '18 at 8:33

















  • To shorten how about using $("form").on("submit") and $(this).serialize()

    – mplungjan
    Nov 15 '18 at 7:46











  • understood. but will that solve problem?

    – Shaik Bajivali
    Nov 15 '18 at 7:50











  • Simplification is always good. Any errors in console or app log?

    – mplungjan
    Nov 15 '18 at 8:00











  • No error messages in console

    – Shaik Bajivali
    Nov 15 '18 at 8:32











  • it just need to store the elements in the jtable in to array and append it to the data field.

    – Shaik Bajivali
    Nov 15 '18 at 8:33
















To shorten how about using $("form").on("submit") and $(this).serialize()

– mplungjan
Nov 15 '18 at 7:46





To shorten how about using $("form").on("submit") and $(this).serialize()

– mplungjan
Nov 15 '18 at 7:46













understood. but will that solve problem?

– Shaik Bajivali
Nov 15 '18 at 7:50





understood. but will that solve problem?

– Shaik Bajivali
Nov 15 '18 at 7:50













Simplification is always good. Any errors in console or app log?

– mplungjan
Nov 15 '18 at 8:00





Simplification is always good. Any errors in console or app log?

– mplungjan
Nov 15 '18 at 8:00













No error messages in console

– Shaik Bajivali
Nov 15 '18 at 8:32





No error messages in console

– Shaik Bajivali
Nov 15 '18 at 8:32













it just need to store the elements in the jtable in to array and append it to the data field.

– Shaik Bajivali
Nov 15 '18 at 8:33





it just need to store the elements in the jtable in to array and append it to the data field.

– Shaik Bajivali
Nov 15 '18 at 8:33












2 Answers
2






active

oldest

votes


















1














By default, jQuery supports json format submissions



data :‘selSubjectIds’:selSubjectIds or $(this).serialize();






share|improve this answer

























  • thanks for the answer. Can you be more specific like where should i put this and which lines has to be replaced?

    – Shaik Bajivali
    Nov 15 '18 at 9:59











  • var data = 'firstName':$("#firstNameInCreateStudent").val()), ......... 'studentSubjects': selSubjectIds data :data

    – Z KK
    Nov 16 '18 at 9:55












  • that was helpful. thanks

    – Shaik Bajivali
    Nov 20 '18 at 11:29


















0















Thanks to Everyone for your efforts.I found my self a way to solve
this as Follows




var arr = "";
$('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
var record = $(this).data('record');
arr += record.subjectId + seperatorForGridCells;

);



Here the arr variable stores every ID as a String by concating with
Some seperator "seperatorForGridCells". Then i used StringTokenizer to
seperate each id and parsed each id from string type to int.







share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314394%2fpass-the-list-of-checked-values-to-controller-by-bean-object%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    By default, jQuery supports json format submissions



    data :‘selSubjectIds’:selSubjectIds or $(this).serialize();






    share|improve this answer

























    • thanks for the answer. Can you be more specific like where should i put this and which lines has to be replaced?

      – Shaik Bajivali
      Nov 15 '18 at 9:59











    • var data = 'firstName':$("#firstNameInCreateStudent").val()), ......... 'studentSubjects': selSubjectIds data :data

      – Z KK
      Nov 16 '18 at 9:55












    • that was helpful. thanks

      – Shaik Bajivali
      Nov 20 '18 at 11:29















    1














    By default, jQuery supports json format submissions



    data :‘selSubjectIds’:selSubjectIds or $(this).serialize();






    share|improve this answer

























    • thanks for the answer. Can you be more specific like where should i put this and which lines has to be replaced?

      – Shaik Bajivali
      Nov 15 '18 at 9:59











    • var data = 'firstName':$("#firstNameInCreateStudent").val()), ......... 'studentSubjects': selSubjectIds data :data

      – Z KK
      Nov 16 '18 at 9:55












    • that was helpful. thanks

      – Shaik Bajivali
      Nov 20 '18 at 11:29













    1












    1








    1







    By default, jQuery supports json format submissions



    data :‘selSubjectIds’:selSubjectIds or $(this).serialize();






    share|improve this answer















    By default, jQuery supports json format submissions



    data :‘selSubjectIds’:selSubjectIds or $(this).serialize();







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 15 '18 at 10:24









    Saeed Zhiany

    1,60141825




    1,60141825










    answered Nov 15 '18 at 9:51









    Z KKZ KK

    111




    111












    • thanks for the answer. Can you be more specific like where should i put this and which lines has to be replaced?

      – Shaik Bajivali
      Nov 15 '18 at 9:59











    • var data = 'firstName':$("#firstNameInCreateStudent").val()), ......... 'studentSubjects': selSubjectIds data :data

      – Z KK
      Nov 16 '18 at 9:55












    • that was helpful. thanks

      – Shaik Bajivali
      Nov 20 '18 at 11:29

















    • thanks for the answer. Can you be more specific like where should i put this and which lines has to be replaced?

      – Shaik Bajivali
      Nov 15 '18 at 9:59











    • var data = 'firstName':$("#firstNameInCreateStudent").val()), ......... 'studentSubjects': selSubjectIds data :data

      – Z KK
      Nov 16 '18 at 9:55












    • that was helpful. thanks

      – Shaik Bajivali
      Nov 20 '18 at 11:29
















    thanks for the answer. Can you be more specific like where should i put this and which lines has to be replaced?

    – Shaik Bajivali
    Nov 15 '18 at 9:59





    thanks for the answer. Can you be more specific like where should i put this and which lines has to be replaced?

    – Shaik Bajivali
    Nov 15 '18 at 9:59













    var data = 'firstName':$("#firstNameInCreateStudent").val()), ......... 'studentSubjects': selSubjectIds data :data

    – Z KK
    Nov 16 '18 at 9:55






    var data = 'firstName':$("#firstNameInCreateStudent").val()), ......... 'studentSubjects': selSubjectIds data :data

    – Z KK
    Nov 16 '18 at 9:55














    that was helpful. thanks

    – Shaik Bajivali
    Nov 20 '18 at 11:29





    that was helpful. thanks

    – Shaik Bajivali
    Nov 20 '18 at 11:29













    0















    Thanks to Everyone for your efforts.I found my self a way to solve
    this as Follows




    var arr = "";
    $('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
    var record = $(this).data('record');
    arr += record.subjectId + seperatorForGridCells;

    );



    Here the arr variable stores every ID as a String by concating with
    Some seperator "seperatorForGridCells". Then i used StringTokenizer to
    seperate each id and parsed each id from string type to int.







    share|improve this answer



























      0















      Thanks to Everyone for your efforts.I found my self a way to solve
      this as Follows




      var arr = "";
      $('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
      var record = $(this).data('record');
      arr += record.subjectId + seperatorForGridCells;

      );



      Here the arr variable stores every ID as a String by concating with
      Some seperator "seperatorForGridCells". Then i used StringTokenizer to
      seperate each id and parsed each id from string type to int.







      share|improve this answer

























        0












        0








        0








        Thanks to Everyone for your efforts.I found my self a way to solve
        this as Follows




        var arr = "";
        $('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
        var record = $(this).data('record');
        arr += record.subjectId + seperatorForGridCells;

        );



        Here the arr variable stores every ID as a String by concating with
        Some seperator "seperatorForGridCells". Then i used StringTokenizer to
        seperate each id and parsed each id from string type to int.







        share|improve this answer














        Thanks to Everyone for your efforts.I found my self a way to solve
        this as Follows




        var arr = "";
        $('#subjectsTableInCreateStudent').find('.jtable-data-row').each(function()
        var record = $(this).data('record');
        arr += record.subjectId + seperatorForGridCells;

        );



        Here the arr variable stores every ID as a String by concating with
        Some seperator "seperatorForGridCells". Then i used StringTokenizer to
        seperate each id and parsed each id from string type to int.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '18 at 10:20









        Shaik BajivaliShaik Bajivali

        368




        368



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314394%2fpass-the-list-of-checked-values-to-controller-by-bean-object%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo