submit editor data to servlet

submit editor data to servlet

Yang.SongYang.Song Posts: 4Questions: 2Answers: 0

I'm stuck getting the editor to submit to servlet. When I click "save", servlet is invoked. However, I'm not seeing data being passed back.

$(document).ready(function() {
     editor = new $.fn.dataTable.Editor( {
        ajax: "/DB7/SaveScreenDataServlet?theSessionId=E831FAE181D44A7F851A150B284672C36710",
        template: '#customEditForm',        
        idSrc: 'id',  //column 0 contains the id field of the screen data table      
        formOptions: { main: { focus: null } },
        table: '#historyTable',    
        display: onPageDisplay( $('#form-container') ),
        fields: [       
    {label: 'Effective Date', name: 'Effective_Dte', id: 'Effective_Dte', type: 'datetime',  format: 'MM/DD/YYYY', opts:{yearRange:100}, attr:{type:'datetime',maxlength:10,placeholder:'  /  /    '}  }
    {label: 'Job_History_ID', name: 'Job_History_ID', id: 'Job_History_ID', type: 'hidden' }
     {label: 'Type', name: 'Job_Type_Code', id: 'Job_Type_Code', type: 'select', options:   
         {label: "CO : Company", value: "CO : Company"},
             {label: "DIV : Division", value: "DIV : Division"},
             {label: "LOC : Location", value: "LOC : Location"},
             {label: "CLASS : Employment Class", value: "CLASS : Employment Class"},
             {label: "EMPCAT : Employment Category", value: "EMPCAT : Employment Category"},
            {label: "JOBCAT : Job Category", value: "JOBCAT : Job Category"},
             {label: "PLAN : Plan Code", value: "PLAN : Plan Code"},
             {label: "UNION : Union Code", value: "UNION : Union Code"} 
        ]}                     
        {label: 'Emp_Employee_ID', name: 'Emp_Employee_ID', id: 'Emp_Employee_ID', type: 'hidden' }
     {label: 'Value', name: 'Job_Value_Code', id: 'Job_Value_Code', type: 'select', options:   
            {label: "A : ABC Company", value: "A : ABC Company"},
            {label: "B : BTF Company", value: "B : BTF Company"},
            {label: "C : CXW Company", value: "C : CXW Company"},
            {label: "D : DYZ Company", value: "D : DYZ Company"},
            {label: "E : ESB Company", value: "E : ESB Company"},
            {label: "F : F Company", value: "F : F Company"},
         ]}                    
         {label: 'revision_id', name: 'revision_id', id: 'revision_id', type: 'hidden' }
       ]} );

I tried changing this line

 ajax: "/DB7/SaveScreenDataServlet?theSessionId=E831FAE181D44A7F851A150B284672C36710",

to

ajax: ({
            url : "/DB7/SaveScreenDataServlet?theSessionId=E831FAE181D44A7F851A150B284672C36710",
            type: "post",
            data : form_data
        }), 

and the screen no longer loads. What am I doing wrong? Thanks!

Answers

  • colincolin Posts: 8,995Questions: 0Answers: 1,500

    However, I'm not seeing data being passed back.

    That sounds like a server-side issue. Have you debugged the server script? Is it being triggered? Does it respond?

    Colin

  • Yang.SongYang.Song Posts: 4Questions: 2Answers: 0

    Yes. The servlet is invoked. But I don't know how to get access to the data on the request object. I looked into it in debugger and all mapping, attributes seems to be null? I'm Thanks!

    I also changed the ajax call a little and it did not help.

    ajax: ({
                url : "/DB7/SaveScreenDataServlet?theSessionId=${theSessionId}",
                type: "post",
                contentType: 'application/json',
                data: function ( d ) {
                    return JSON.stringify( d );
                }
            }),     
    
    
  • allanallan Posts: 51,920Questions: 1Answers: 7,873 Site admin

    data : form_data

    I'd say don't do that. Just let Editor submit the data as normal (it will do so with the parameters documented here).

    How do you normally read POST data in the servlet? I don't know any Java at all I'm afraid!

    Allan

Sign In or Register to comment.