[CLOSED] ModelState

  1. #1

    [CLOSED] ModelState

    Hi,

    There is an AjaxFormResult which extends the actionResult. Within this class the following code method is overriden

    public override void ExecuteResult(ControllerContext context) 
     
            { 
     
                CompressionUtils.GZipAndSend(new ClientConfig().Serialize(this)); 
     
            }
    I would like to understand where the controller ModelState is populated with errors? Is it done within the ClientConfig class?

    Any idea?

    Romuald.
    Last edited by Daniil; Feb 09, 2011 at 5:01 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Ext.Net form doesn't use ModelState.
    You have to fill Errors collection of AjaxFormResult class
  3. #3
    Hello,

    It's right that Ext.Net form doesn't use ModelState. But AjaxFormResult is not a mvc standard. I think It's provided by Ext. So I just want to understand how it deals with ModelState. At which state it populates the Modelstate with errors.

    Romuald
  4. #4
    Hi,

    AjaxFormResult works with Ext.Net FormPanel requests only. Therefore AjaxFormResult doesn't use ModelState at all

    I guess that ModelState is populated by controller class
    I suggest to investigate ASP.NET MVC source code to understand how ModelState is built (i can assume that ModelState is built when controller instance is created and based on submitted values (values from query string and submitted form))
  5. #5
    So in order to track the events such as "actioncomplete" or "actionfailed" of the formPanel my controller must return an insatnce of AjaxFormResult, isn't it? Is there another object I can use instead of AjaxFormResult to track errors within the controller?

    Romuald
  6. #6
    Hi,

    I am not sure that understood you. Which "actioncomplete" or "actionfailed" events do you mean?
    Can you provide more details about what you try to accomplish?

    AjaxFormResult doesn't track errors. That class build correct response for FormPanel submit request (success flag or error messages)
  7. #7
    <ext:FormPanel ID="formPanel" runat="server" Border="false" Url="~/getController/getAction"
                    AutoScroll="true" MinWidth="870">
                    <Items>
                    </Items>
                    <Listeners>
                        <ActionComplete Fn="function(){ manageCompleteResponse();}" />
                        <ActionFailed Fn="function(){ manageFailedResponse();}" />
                    </Listeners>
                </ext:FormPanel>
    Above you have an example. What I would like to know is the "getAction" must return an AjaxFormResult in order for formPanel to call according to the response the actionComplete event or the actionFailed event.

    Hope you understand now waht I mean and thank you in advance.

    Romuald
  8. #8
    I found the solution to my question:

    My controller should return a JSON object as result which will have following:


    would process the following server response for a successful submission:
    { 
    "success":true, // note this is Boolean, not string 
    "msg":"Consignment updated"
    }
    and the following server response for a failed submission:
    { 
    "success":false, // note this is Boolean, not string 
    "msg":"You do not have permission to perform this operation"
    }
    Thank for your replies

    Romuald
  9. #9
    Hi,

    FormPanel actions expect json object
    Submit
    {
        success: false,
        errors: {
            clientCode: "Client not found",
            portOfLoading: "This field must not be null"
        }
    }
    http://dev.sencha.com/deploy/dev/doc....Action.Submit

    Load
    {
        success: true,
        data: {
            clientName: "Fred. Olsen Lines",
            portOfLoading: "FXT",
            portOfDischarge: "OSL"
        }
    }
    http://dev.sencha.com/deploy/dev/doc...rm.Action.Load

    So, you have to return json object (for example, JsonResult class)
  10. #10
    Thank for your reply. I have with it more information

    Romuald.

Posting Permissions