Hi Shaun,

    Thanks for the note, I had found a workaround. It's too bad nonetheless, 
this seems a pretty serious oversight on Adobe's behalf.  Every other framework 
I've ever worked with, include simple browser XHOR can be made to permit sync 
requests.. Onto the next stumbling block!

Cheers.
Alex



  ----- Original Message ----- 
  From: shaun 
  To: [email protected] 
  Sent: Tuesday, March 13, 2007 5:03 PM
  Subject: Re: [flexcoders] Synchronous HTTPService possible? Need to verify 
edit inside of Edit Event..


  Hi,

  Alex wrote:
  > Quick question,
  > 
  > 
  > I'm trying to devise a table-edit view of a set of database tables,
  > and am successfully pulling records using e4x etc.
  > 
  > At the cell-edition stage, I'm capturing an "itemEditEnd" event on my
  > DataGrid, and that's going well also.
  > 
  > My question however, surrounds actual edition, and the cancellation of
  > an edit event.
  > 
  > The code should look like this:
  > 
  > private function editHandler( e:DataGRidEvent ):void{
  > if( e.reason == DataGridEventReason.CANCELLED )
  > return;
  > 
  > // get the new input
  > var newData:String = TextInput(
  > e.currentTarget.itemEditorInstance).text;
  > 
  > // request the edit
  > ??
  > 
  > if( "edit was bad" ){
  > e.preventDefault();
  > // TextInput( dataGrid.itemEditorInstance ).errorString = "Invalid
  > input";
  > }
  > }
  > 
  > 
  > "Requesting the edit" above, involves using HTTPService to send the edit
  > request to the server, which will respond with OK, or NOT OK. How can I
  > "wait" for an HTTPService request inside of that function, so that I can
  > call e.preventDefault() if required? AFAIK, the HTTPService only works
  > with a callback-type model?
  > 
  > Can I synchronize and wait on a lock like in Java in this case?
  > 

  No, I dont think you can do it like that.

  How about moving the "if (edit is bad)" check to the result handler of 
  the http service. Then depending on whether you prevented the default 
  event from happening or not in the itemEditEnd handler, update the value 
  accordingly.

  It might look something like this:

  get the original value from the model.
  get the new value from the model.
  dispatch the validation http service event with the old and new value
  on result of the validation event
  if the result is NOT OK then
  set the data in the model back to the old value
  set the error message
  end if
  end on result

  I guess, depending on your architecture, you could just move your
  if("edit was bad" ){ } code into another method and have the component 
  implement the IResponder interface to invoke that method when the 
  validation service is done.

  Then again, there are validation classes that are probably the best 
  place to do this rather than the itemEditEnd event handler - not sure.

  HTH.

  cheerio,
  shaun


   

Reply via email to