Changeset 884


Ignore:
Timestamp:
09/13/11 09:54:27 (14 years ago)
Author:
lgiessmann
Message:

gdl-frontend: Widgets: refactred the update handler for http://textgrid.org/serviceregistry/model/types/Hash-Object

Location:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java

    r882 r884  
    227227                        if (200 == response.getStatusCode()) {
    228228                                if(edited){
    229                                         //TODO: implement
     229                                        String delObj = response.getText();
     230                                        try{
     231                                                String url = URL.encode(CommitCallback.this.DELETE_REUQEST_URL);
     232                                                RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, url);
     233                                                builder.setHeader("Content-type", "application/json");
     234                                               
     235                                                builder.sendRequest(delObj, new HashObjectDeleteRequest(delObj, this.objectToBeSend));                                         
     236                                        }catch(RequestException e){
     237                                                Window.alert("could not update the topic " + delObj);
     238                                                //TODO: reset page
     239                                        }
    230240                                } else {
    231241                                        Window.alert("could not commit the topic with the psi " + psi + " since it already exists");
     
    257267       
    258268       
     269        private class HashObjectDeleteRequest implements RequestCallback{
     270                private String objectToBeDeleted = null;
     271                private String objectToBeSend = null;
     272               
     273               
     274                @SuppressWarnings("unused")
     275                private HashObjectDeleteRequest(){}
     276               
     277               
     278                public HashObjectDeleteRequest(String objectToBeDeleted, String objectToBeSend){
     279                        this.objectToBeDeleted = objectToBeDeleted;
     280                        this.objectToBeSend = objectToBeSend;
     281                }
     282               
     283               
     284                @Override
     285                public void onResponseReceived(Request request, Response response) {
     286                        if (200 == response.getStatusCode()) {
     287                                try{
     288                                        String commitUrl = URL.encode(CommitCallback.this.COMMIT_REQUEST_URL);
     289                                        RequestBuilder commitBuilder = new RequestBuilder(RequestBuilder.POST, commitUrl);
     290                                        commitBuilder.setHeader("Content-type", "application/json");
     291                                        commitBuilder.sendRequest(this.objectToBeSend, new HashObjectCommitRequest(this.objectToBeSend));
     292                                }catch(RequestException e){
     293                                        Window.alert("could not commit the data: " + this.objectToBeSend);
     294                                        // TODO: reset web page
     295                                }
     296                        } else {
     297                                Window.alert("update operation of the object " + this.objectToBeDeleted + " failed: " + response.getStatusCode() + "(" + response.getStatusText() + ")\n" + response.getText());
     298                        }
     299                }
     300               
     301
     302                @Override
     303                public void onError(Request request, Throwable exception) {
     304                        Window.alert("could not update the data: " + this.objectToBeDeleted);
     305                        // TODO: reset web page
     306                }
     307        }
     308       
     309       
    259310        private class HashObjectCommitRequest implements RequestCallback {
    260311                private String objectToBeSend = null;
  • TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java

    r879 r884  
    5454                                                builder.setHeader("Content-type", "application/json");
    5555                                               
    56                                                 //RootPanel.getBodyElement().setInnerText(delObj.toString()); // TODO: remove
    5756                                                builder.sendRequest(delObj.toString(), new DeleteRequest(delObj, env));
    5857                                        }catch(RequestException e){
Note: See TracChangeset for help on using the changeset viewer.