brOOper / gwt-cal

Automatically exported from code.google.com/p/gwt-cal
0 stars 0 forks source link

Have a Row version of UpdateEvent #65

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Description of the new feature:
I need to cancel the UpdateEvent generated by drag/drop after had sent a 
request to a database.

Use Case:
User drags and drops an appointment in a new day and confirm the action in 
alert window. At this point a request with new start and new end dates is sent 
to a database for save it. But if the comunication handler fail to contact the 
database, the calendar must be restored and show the previous appointment. Do 
you have any ideas?

I think about a very row UpdateHandler version that not adds immediatly 
appointment to calendar, but leave the developer to do that. What do you think 
about?

Code / psuedo-code:

display.getCalendar().addUpdateHandler(new UpdateHandler<Appointment>() {

          @Override
          public void onUpdate(UpdateEvent<Appointment> event) {
        sendRequestToDb(event.getTarget());     

          }
}

sendRequestToDb(Appointment appt){
        RPCcallToDb(appt, new RPCcall){

               @Override
        protected void handleFailure(final Throwable cause) {
        Log.error("Handle Failure:", cause);
        Window.alert(SERVER_ERROR);
                //HERE HOW RESTORE THE CALENDAR???
            }

        @Override
        protected void handleSuccess(final DatabaseDirvRpcResult  result) {
                Log.error("Handle Success!"); 
                }
}

Thanks!
Bye

Original issue reported on code.google.com by fornasie...@gmail.com on 9 Jul 2010 at 3:54

GoogleCodeExporter commented 8 years ago
I have a rollback() method in the AppointmentManager class that will basically 
"undo" previous last update. I recommend you expose this method in the 
CalendarWidget in your local copy of trunk and see if it meets your needs.

Try it out and let me know.

Original comment by Brad.Ryd...@gmail.com on 12 Jul 2010 at 3:19

GoogleCodeExporter commented 8 years ago
Yes, it's what I did.
I advice to put this mod in the new version.
Thanks!

Original comment by fornasie...@gmail.com on 12 Jul 2010 at 3:30