flash remoting and refreshing a grid after database update

View: New views
3 Messages — Rating Filter:   Alert me  

flash remoting and refreshing a grid after database update

by tim barth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am using flash remoting to update data and refresh a grid in a flash cfform.  My goal is to have the user update data in the form (creating a call to a CFC that that performs a SQL update), then to update the data in a grid.

Problem is that when I try to make the two events (update, display) happen in sequence, they seem to happen at the same time such that the data in the grid usually does not reflect the change the user just made to the database.  If I make the grid data load function independent of the update function (forcing the user to click a button), the grid refreshes fine.

I'm sure I am missing something simple ... any help?

Simplified examples:

I have tried multiple function calls tied to the button:
onclick="updatethedata('test1','test2'); refreshthegrid();"

and I have tried putting that stuff in the scripts in my cfform as well:

function updatethedata(param1:String, param2:String){
     var responseHandler = {};
     var testresult:String;
     responseHandler.onResult = function( results: Object ):Void {
         //when results are back, populate the grid -- the function is being called, but it pulls data before the database is updated with data
         refreshthegrid();
     }
     responseHandler.onStatus  = function( stat: Object ):Void {
         //if there is any error, show an alert
         alert("Error while calling cfc:" + stat.description);
     }

     // do the update
     myService = connection.getService("flashRemotingResponder", responseHandler );
     <cfoutput>
     var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");
    var myService:mx.remoting.NetServiceProxy;
    myService = connection.getService("flashRemotingResponder", responseHandler);
   myService.updateRegistrant(param1,param2);
   </cfoutput>
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-flash/message.cfm/messageid:298
Subscription: http://www.houseoffusion.com/groups/cf-flash/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.30

Re: flash remoting and refreshing a grid after database update

by tim barth :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I figured this out ... put a 1/4 second sleep in each of the get data cfcs - works like a charm.

Using this code before I retrieve a query in my CFC:
<cfscript>
      thread = CreateObject("java", "java.lang.Thread");
      thread.sleep(250);
</cfscript>

...that way the CFC retrieving data waits for the updating CFC to finish.

> I am using flash remoting to update data and refresh a grid in a flash
> cfform.  My goal is to have the user update data in the form (creating
> a call to a CFC that that performs a SQL update), then to update the
> data in a grid.
>
> Problem is that when I try to make the two events (update, display)
> happen in sequence, they seem to happen at the same time such that the
> data in the grid usually does not reflect the change the user just
> made to the database.  If I make the grid data load function
> independent of the update function (forcing the user to click a
> button), the grid refreshes fine.
>
> I'm sure I am missing something simple ... any help?
>
> Simplified examples:
>
> I have tried multiple function calls tied to the button:
> onclick="updatethedata('test1','test2'); refreshthegrid();"
>
> and I have tried putting that stuff in the scripts in my cfform as
> well:
>
> function updatethedata(param1:String, param2:String){
     
> var responseHandler = {};
     
> var testresult:String;
     
> responseHandler.onResult = function( results: Object ):Void {
         
> //when results are back, populate the grid -- the function is being
> called, but it pulls data before the database is updated with data
         
> refreshthegrid();
     
> }
     
> responseHandler.onStatus  = function( stat: Object ):Void {
         
> //if there is any error, show an alert
         
> alert("Error while calling cfc:" + stat.description);
     
> }
>
     
> // do the update
     
> myService = connection.getService("flashRemotingResponder",
> responseHandler );
     
> <cfoutput>
     
> var connection:mx.remoting.Connection = mx.remoting.NetServices.
> createGatewayConnection("http://#cgi.
> HTTP_HOST#/flashservices/gateway/");
   
> var myService:mx.remoting.NetServiceProxy;
   
> myService = connection.getService("flashRemotingResponder",
> responseHandler);
   
> myService.updateRegistrant(param1,param2);
   
> </cfoutput>
> }


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-flash/message.cfm/messageid:299
Subscription: http://www.houseoffusion.com/groups/cf-flash/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.30

Parent Message unknown Re: flash remoting and refreshing a grid after database update

by Tyron Foston :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


was that the min amount of server sleep needed? did i work at say .1 seconds?

Tyron E. Foston

Comedy Style: Industrial Strength

Http://www.TyronFoston.com

http://www.myspace.com/tyronfoston

--- On Wed, 5/20/09, tim barth <tim@...> wrote:

From: tim barth <tim@...>
Subject: Re: flash remoting and refreshing a grid after database update
To: "cf-flash" <cf-flash@...>
Date: Wednesday, May 20, 2009, 12:17 PM


I figured this out ... put a 1/4 second sleep in each of the get data cfcs - works like a charm.

Using this code before I retrieve a query in my CFC:
<cfscript>
      thread = CreateObject("java", "java.lang.Thread");
      thread.sleep(250);
</cfscript>

...that way the CFC retrieving data waits for the updating CFC to finish.

> I am using flash remoting to update data and refresh a grid in a flash
> cfform.  My goal is to have the user update data in the form (creating
> a call to a CFC that that performs a SQL update), then to update the
> data in a grid.
>
> Problem is that when I try to make the two events (update, display)
> happen in sequence, they seem to happen at the same time such that the
> data in the grid usually does not reflect the change the user just
> made to the database.  If I make the grid data load function
> independent of the update function (forcing the user to click a
> button), the grid refreshes fine.
>
> I'm sure I am missing something simple ... any help?
>
> Simplified examples:
>
> I have tried multiple function calls tied to the button:
> onclick="updatethedata('test1','test2'); refreshthegrid();"
>
> and I have tried putting that stuff in the scripts in my cfform as
> well:
>
> function updatethedata(param1:String, param2:String){
     
> var responseHandler = {};
     
> var testresult:String;
     
> responseHandler.onResult = function( results: Object ):Void {
         
> //when results are back, populate the grid -- the function is being
> called, but it pulls data before the database is updated with data
         
> refreshthegrid();
     
> }
     
> responseHandler.onStatus  = function( stat: Object ):Void {
         
> //if there is any error, show an alert
         
> alert("Error while calling cfc:" + stat.description);
     
> }
>
     
> // do the update
     
> myService = connection.getService("flashRemotingResponder",
> responseHandler );
     
> <cfoutput>
     
> var connection:mx.remoting.Connection = mx.remoting.NetServices.
> createGatewayConnection("http://#cgi.
> HTTP_HOST#/flashservices/gateway/");
   
> var myService:mx.remoting.NetServiceProxy;
   
> myService = connection.getService("flashRemotingResponder",
> responseHandler);
   
> myService.updateRegistrant(param1,param2);
   
> </cfoutput>
> }




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-flash/message.cfm/messageid:300
Subscription: http://www.houseoffusion.com/groups/cf-flash/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.30