Results 1 to 4 of 4

Thread: Ext JS support for PUT method

  1. #1
    Sencha User
    Join Date
    Jun 2017
    Posts
    2

    Default Ext JS support for PUT method

    Hey everyone,

    I am relatively new to Ext JS but I am building an address book application just to kind of get my feet wet and create and understanding how how the framework works. I am attempting to generate an AJAX PUT method to my backend which is just java running on tomcat 8.5.15 but I get a 405 error everytime I try to use my PUT request. I am wondering if Ext JS 6 does not support put methods as my console output with the developer tools states that only GET and POST requests are allowed?

    Please ignore the commented out areas as they are things I previously did wrong or things I have previously attempted for various aspects in this learning process. Any help would be greatly appreciated.

    Ext.define('myApp.view.main.newStudentFormController',{
    extend:'Ext.app.ViewController',
    alias:'controller.newStudent-form',

    store:'personnel',
    model:'main',


    listen: {
    controller : {
    '*' : {
    updateStudent :'updateStudentHere'
    }
    }
    },

    onCancel:function(){
    varview=this.getView();
    view.destroy();
    },

    updateStudentHere:function(selected){
    varview=this.getView();
    varstore=Ext.getStore('student');

    view.lookupReference('studentID').setValue(selected.data.studentID);
    view.lookupReference('firstName').setValue(selected.data.firstName);
    view.lookupReference('lastName').setValue(selected.data.lastName);
    view.lookupReference('heightft').setValue(selected.data.heightft);
    view.lookupReference('weight').setValue(selected.data.weight);
    view.lookupReference('phoneNumber').setValue(selected.data.phoneNumber);


    },

    onSubmit:function(button){
    varview=this.getView();
    varstore=Ext.getStore('student');
    varform=button.up('form').getForm();

    varrecord=Ext.getStore('student').getById(view.lookupReference('studentID').value);
    Ext.getStore('student').remove(record);

    if(view.lookupReference('studentID').value===null){
    alert("Data POST");
    Ext.Ajax.request({
    method:'POST',
    cors:true,
    useDefaultXhrHeader :false,
    url:'http://localhost:8080/LearnGradle/students',
    // headers: {
    // 'Accept': 'application/json',
    // 'Content-Type': 'application/json'
    // },
    dataType:'json',
    contentType:'application/json',
    accept:'application/json',
    jsonData:form.getValues(),//this finally fixed the 415 error
    // params:{
    // data: Ext.encode(form.getValues())
    // },
    success:function(response, opts){
    //alert(response.responseText);
    varstudent=JSON.parse(response.responseText);

    store.add({
    studentID:student.studentID,
    firstName:student.firstName,
    lastName:student.lastName,
    heightft:student.heightft,
    weight:student.weight,
    phoneNumber:student.phoneNumber
    });
    },
    failure:function(){
    alert("Add Failed");
    }
    });
    }//if
    elseif(view.lookupReference('studentID').value!==null){
    alert("Data PUT")
    console.log(view.lookupReference('studentID').value);
    Ext.Ajax.request({
    method:'PUT',
    cors:true,
    useDefaultXhrHeader :false,
    url:'http://localhost:8080/LearnGradle/students/'+view.lookupReference('studentID').value,
    // headers: {+
    // 'Accept': 'application/json',
    // 'Content-Type': 'application/json'
    // },
    dataType:'json',
    contentType:'application/json',
    accept:'application/json',
    jsonData:form.getValues(),//this finally fixed the 415 error
    // params:{
    // data: Ext.encode(form.getValues())
    // },
    success:function(response, opts){
    varstudent=JSON.parse(response.responseText);

    store.add({
    studentID:student.studentID,
    firstName:student.firstName,
    lastName:student.lastName,
    heightft:student.heightft,
    weight:student.weight,
    phoneNumber:student.phoneNumber
    });
    },
    failure:function(){
    alert('Update Failed Student with ID: '+view.lookupReference('studentID').value+' not found');
    }
    });

    }

    //works for front end only
    // store.add({
    // studentID: view.lookupReference('studentID').value,
    // firstName: view.lookupReference('firstName').value,
    // lastName: view.lookupReference('lastName').value,
    // heightft: view.lookupReference('heightft').value,
    // weight: view.lookupReference('weight').value,
    // phoneNumber: view.lookupReference('phoneNumber').value
    // });

    view.destroy();
    }
    }
    );


  2. #2
    Sencha Premium Member
    Join Date
    Dec 2012
    Location
    Seattle, WA
    Posts
    423
    Answers
    34

    Default

    The Ajax singleton only has GET and POST. Use a REST proxy if you want to use PUT and DELETE.

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    45
    Answers
    1

    Default

    If proxy type "Direct" does support PUT, DELETE?

  4. #4
    Sencha Premium Member richardvd's Avatar
    Join Date
    Jun 2011
    Location
    NL
    Posts
    253
    Answers
    22

Similar Threads

  1. object dosent support this property or method
    By santoshsatav in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 13 Jan 2011, 12:26 AM
  2. Object doesn't support this property or method
    By xjpmauricio in forum Ext 3.x: Help & Discussion
    Replies: 12
    Last Post: 22 Oct 2010, 3:21 AM
  3. Object don't support attribute or method
    By edwardking in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 3 Sep 2010, 12:54 AM
  4. CheckboxGroup should support itemId in its getBox method
    By twk3 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 15 Jun 2010, 10:25 AM
  5. Object doesn't support this property or method
    By dotcomuser in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 15 Jan 2010, 3:26 AM

Tags for this Thread

Posting Permissions

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