Results 1 to 5 of 5

Thread: formpanel restful

  1. #1
    Sencha User
    Join Date
    Jan 2010
    Posts
    3

    Question formpanel restful

    hi, everybody:
    in my testing project, I used the spring3 in the server side and extjs3 in the client side, I want to use formpanel to submit data to server:

    client code
    var simple = new Ext.FormPanel({
    labelWidth: 75, // label settings here cascade unless overridden
    url:'account/new',
    id:'accountForm',
    frame:true,
    title: 'Simple Form',
    bodyStyle:'padding:5px 5px 0',
    width: 350,
    defaults: {width: 230},
    defaultType: 'textfield',
    items: [{
    fieldLabel: 'Name',
    name: 'name',
    allowBlank:false
    },{
    fieldLabel: 'balance',
    name: 'balance'
    },{
    fieldLabel: 'equityAllocation',
    name: 'equityAllocation'
    }, {
    fieldLabel: 'renewalDate',
    name: 'renewalDate',
    }
    ],
    buttons: [{
    text: 'Save',
    handler:function(){
    var d=Ext.getCmp("accountForm");
    if(d.getForm().isValid()){
    d.getForm().submit({
    restful:true,
    waitMsg:"process....",
    success:function(e,g){
    Ext.ux.Toast.msg("msg","success?");

    },
    failure:function(e,f){
    switch (f.failureType) {
    case Ext.form.Action.CLIENT_INVALID:
    Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
    break;
    case Ext.form.Action.CONNECT_FAILURE:
    Ext.Msg.alert('Failure', 'Ajax communication failed');
    break;
    case Ext.form.Action.SERVER_INVALID:
    Ext.Msg.alert('Failure', f.result.msg);
    }

    }
    });
    }
    }
    },{
    text: 'Cancel'
    }]
    });

    server code:
    @RequestMapping(value="/new")
    public @ResponseBody Map<String, ? extends Object> create(@RequestBody Account account, HttpServletResponse response) {
    Set<ConstraintViolation<Account>> failures = validator.validate(account);
    if (!failures.isEmpty()) {
    response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    return validationMessages(failures);
    } else {
    accounts.put(account.assignId(), account);
    return Collections.singletonMap("id", account.getId());
    }
    }

    after I click save , firebug display:

    post tab:

    ??application/x-www-form-urlencoded
    balanceaequityAllocationanamearenewalDatea???
    name=a&balance=a&equityAllocation=a&renewalDate=a


    html tab:

    HTTP Status 404 -

    type Status report
    message
    description The requested resource () is not available.


    can anybody tell me why, and how to realize the function?
    thanks
    Attached Images Attached Images
    • File Type: jpg a.jpg (17.6 KB, 4 views)
    • File Type: jpg b.jpg (20.6 KB, 2 views)

  2. #2
    Sencha User
    Join Date
    Jan 2010
    Posts
    3

    Default

    anybody know it ?

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

    Default

    Are you sure you've setup Spring correctly? A 404 error usually means that the server doesn't have a handler for that URL.

  4. #4
    Sencha User
    Join Date
    Jan 2010
    Posts
    3

    Default

    I use spring sample mvc-ajax, so the spring is correct, and the sample use jquery to submit the data.

  5. #5
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Amsterdam, The Netherlands
    Posts
    245

    Default

    We're also using Spring MVC. It seems to me a case that the mapping is not correct. I would suggest you use the <c:url tag to point to the right context.

    Does your Controller have the @Controller annotation? Also make sure that your web.xml is redirecting you to the right servlet.

    We don't use REST in your case, but it shouldn't differ that much...

Similar Threads

  1. ExtJS 3.3 and RESTful
    By bradjen in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 8 Mar 2011, 2:58 AM
  2. Restful DELETE IE
    By j.joslet in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 2 Feb 2011, 11:00 AM
  3. Need help with RESTful Example
    By philance in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 21 Jul 2009, 3:50 AM
  4. Help in restful example
    By pop k in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 24 Jun 2009, 11:04 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
  •