1. #1
    Ext User
    Join Date
    Jan 2010
    Posts
    3
    Vote Rating
    0
    Shivanshu is on a distinguished road

      0  

    Default [Resolved] Facing Problem In Saving A UI Document

    [Resolved] Facing Problem In Saving A UI Document


    I am trying to save a Notes document using

    interviewSession.uidoc.save();

    where interviewSession is a variable in which Grid panel is defined.

    The Screen Shot of Problem is :

    [IMG]file:///C:/DOCUME%7E1/TASKER%7E1.TXP/LOCALS%7E1/Temp/moz-screenshot.png[/IMG]Problem.jpg

    On analysing the code throught fire bug the json response is as mentioned below:
    Json Response.jpg

    This response is not evaluated properly by ext.nd. I tried to update it using $$Return field ... But it didn't helped.

    If any one has encountered this problem before, please help me out .

    Thanks In Advance

  2. #2
    Ext User
    Join Date
    Jan 2010
    Posts
    3
    Vote Rating
    0
    Shivanshu is on a distinguished road

      0  

    Default


    I think I have found a solution.
    On WebQuerySave an agent is triggered, which returns JSON response like.

    Print |Content-Type:text/json|
    Print |{"success" : true}|


    It overrides the default "Form Processed" response. As mentioned in the screen shot above

  3. #3
    Sencha - Services Team
    Join Date
    Mar 2007
    Location
    Foristell, MO
    Posts
    1,109
    Vote Rating
    3
    jratcliff is on a distinguished road

      0  

    Default


    Yes, that is correct. For an "Ajax" type save you want the agent to return text/json or application/json as the content type. If you look at the tasks.nsf db that comes with the Ext.nd zip download file you can see an example of an agent that is called that returns application/json as the content type.

    Also, since the "default" for Ext.nd.UIDocument is to do an "Ajax" save and not a normal form submit, you need to write a handler to handle success and failure conditions. Remember that success and failure as far as Ext is concerned is determined by the success property returned in the JSON. success : true will call your success handler and success : false will call your failure handler.

    Look at the taskUISimple.js to see an example where the .save() method is called but with success and failure handlers defined to handle the response from the server.

  4. #4
    Ext User
    Join Date
    Jan 2010
    Posts
    3
    Vote Rating
    0
    Shivanshu is on a distinguished road

      0  

    Default


    Thanks A Lot, For Explanation

  5. #5
    Sencha User
    Join Date
    Mar 2011
    Location
    Moscow, Russia
    Posts
    11
    Vote Rating
    0
    _Vovka_ is on a distinguished road

      0  

    Question


    Hi.

    I need to save ext.uidoc and when run some code on server side. Why my 'some code' run before save although save is after in code:
    Code:
        if (this.Ext.nd.currentUIDocument.editMode) {
            Request.save();        
        }
    
        var resp = GetFromServer('StartAction', actUNID);
    
    ...
    
    function GetFromServer(actionName, data) {
    ... 
        xmlHttp.open('GET', sendURL, false);
        xmlHttp.send (null);    
    ...
    }
    
    ...
    
    var Request = function() {
    
        return {
              save : function(bClose) {
               ...
                   this.uidoc.save({...})
        }
    }();
    
    
    Ext.onReady(Request.init, Request, true)

    Is where any possibility to call directly some like this: this.Ext.nd.currentUIDocument.save() and when continue to run other code?
    Last edited by jratcliff; 8 Feb 2012 at 8:26 AM. Reason: added code tags to make the code readable

  6. #6
    Sencha - Services Team
    Join Date
    Mar 2007
    Location
    Foristell, MO
    Posts
    1,109
    Vote Rating
    3
    jratcliff is on a distinguished road

      0  

    Default


    Quote Originally Posted by _Vovka_ View Post
    Hi.

    I need to save ext.uidoc and when run some code on server side. Why my 'some code' run before save although save is after in code:
    This is because the this.uidoc.save() call is Asynchronous. You need to define a success handler in the .save() call and from there, run your other code.

    Something like this
    Code:
        if (this.Ext.nd.currentUIDocument.editMode) {
            Request.save();        
        }
    
    ...
    
    function GetFromServer(actionName, data) {
    ... 
        xmlHttp.open('GET', sendURL, false);
        xmlHttp.send (null);    
    ...
    }
    
    ...
    
    var Request = function() {
    
        return {
              save : function(bClose) {
               ...
                   this.uidoc.save({
                        success: function() {
                            var resp = GetFromServer('StartAction', actUNID);
                        },
                        failure: function() {
                            // do something else
                        }
                   });
        }
    }();
    
    
    Ext.onReady(Request.init, Request, true)
    Jack Ratcliff
    Sencha Inc, Green bleeding Senchan

    How to report a bug:
    http://www.sencha.com/forum/showthre...o-report-a-bug

Thread Participants: 2