List of usage examples for com.google.gwt.http.client RequestBuilder GET
Method GET
To view the source code for com.google.gwt.http.client RequestBuilder GET.
Click Source Link
From source file:com.charlie.client.panels.SonglistPanel.java
License:Open Source License
public void addEventHandlers() { Controller.getEventBus().addHandler(GetRecentlyUploadedSongsFromUserAndAllFriendsEvent.TYPE, new GetRecentlyUploadedSongsFromUserAndAllFriendsEventHandler() { @Override// w w w . j a v a 2 s. com public void handle(Long userId) { setTitleForContentPanel("Playlist - Recently Uploaded"); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.RECENLTY_UPLOADED); loader.load(); } }); Controller.getEventBus().addHandler(GetRecentlyUploadedSongsFromAllEvent.TYPE, new GetRecentlyUploadedSongsFromAllEventHandler() { @Override public void handle(Long userId) { Controller.getIntsance().setSongRetrievalType(SongRetrievalType.RECENLTY_UPLOADED_ALL); loader.load(); } }); Controller.getEventBus().addHandler(ShowNowPlayingEvent.TYPE, new ShowNowPlayingEventHandler() { @Override public void handle() { setTitleForContentPanel("Playlist - Now Playing"); grid.getStore().removeAll(); grid.getStore().add(Controller.getPlaylistManager().getPlaylist()); } }); Controller.getEventBus().addHandler(SongFinishedLoadingEvent.TYPE, new SongFinishedLoadingEventHandler() { @Override public void handle(SongModelData song) { } }); Controller.getEventBus().addHandler(PlaySongEvent.TYPE, new PlaySongEventHandler() { @Override public void handle(SongModelData song, Integer volume) { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "servlet/albumArtwork?artist=" + URL.encode(song.getArtist()) + "&album=" + URL.encode(song.getAlbum())); try { selectSongOnGrid(song); Window.setTitle(song.getArtist() + " - " + song.getSongName()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); Controller.getEventBus().addHandler(GetCollectiveSongsForUserEvent.TYPE, new GetCollectiveSongsForUserEventHandler() { @Override public void handle(Long userId) { setTitleForContentPanel("Playlist - Collective Songs For User"); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.USER_COLLECTIVE); collectiveUserId = userId; loader.load(); } }); Controller.getEventBus().addHandler(RandomizePlaylistEvent.TYPE, new RandomizePlaylistEventHandler() { @Override public void handle() { grid.mask("Shuffling..."); randomizePlaylist(); grid.unmask(); } }); Controller.getEventBus().addHandler(UnrandomizePlaylistEvent.TYPE, new UnrandomizePlaylistEventHandler() { @Override public void handle() { unrandomizePlaylist(); } }); Controller.getEventBus().addHandler(PlaylistsNeedReloadingEvent.TYPE, new PlaylistsNeedReloadingEventHandler() { @Override public void handle() { PlaylistModelData model = new PlaylistModelData(); model.setUserId(Controller.getIntsance().getUserId()); SiteServiceImpl.getInstance().getPlaylists(model, Controller.getIntsance().getUserId(), new AsyncCallback<List<PlaylistModelData>>() { @Override public void onSuccess(List<PlaylistModelData> result) { Controller.getEventBus().fireEvent(new PlaylistsListLoadedEvent(result)); } @Override public void onFailure(Throwable caught) { } }); } }); Controller.getEventBus().addHandler(GetSongsForUserAndAllFriendsEvent.TYPE, new GetSongsForUserAndAllFriendsEventHandler() { @Override public void handle(Long userId) { Controller.getIntsance().setSongRetrievalType(SongRetrievalType.ALL_USERS); loader.load(); } }); Controller.getEventBus().addHandler(GetSongsForAllEvent.TYPE, new GetSongsForAllEventHandler() { @Override public void handle(Long userId) { setTitleForContentPanel("Playlist - All Music"); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.ALL_USERS); loader.load(); } }); Controller.getEventBus().addHandler(GetCollectiveSongsForUserAndAllFriendsEvent.TYPE, new GetCollectiveSongsForUserAndAllFriendsEventHandler() { @Override public void handle(Long userId) { // setTitleForContentPanel("Playlist - The Collective"); // starCountcolumn.setHeader("# Users"); setTitleForContentPanel("Playlist - The Collective"); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.COLLECTIVE); loader.load(); } }); Controller.getEventBus().addHandler(PlaylistsListLoadedEvent.TYPE, new PlaylistsListLoadedEventHandler() { @Override public void handle(List<PlaylistModelData> playlists) { playlistSubMenu.removeAll(); playlistSubMenu.add(newPlaylist); playlistSubMenu.add(new SeparatorMenuItem()); for (final PlaylistModelData playlistModelData : playlists) { playlistSubMenu .add(new MenuItem(playlistModelData.getName(), new SelectionListener<MenuEvent>() { @Override public void componentSelected(MenuEvent ce) { Controller.getEventBus().fireEvent( new AddSongToPlaylistEvent(playlistModelData, getSelectedSongs())); } })); } playlistTopLevelMenu.setSubMenu(playlistSubMenu); } }); Controller.getEventBus().addHandler(PlayPlaylistEvent.TYPE, new PlayPlaylistEventHandler() { @Override public void handle(PlaylistModelData playlist) { setTitleForContentPanel("Playlist - Playing playlist [" + playlist.getName() + "]"); Controller.getIntsance().setPlaylist(playlist); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.PLAYLIST); loader.load(); } }); Controller.getEventBus().addHandler(EditPlaylistEvent.TYPE, new EditPlaylistEventHandler() { @Override public void handle(PlaylistModelData playlist) { setTitleForContentPanel("Playlist - Editing playlist [" + playlist.getName() + "]"); Controller.getIntsance().setPlaylist(playlist); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.EDIT_PLAYLIST); loader.load(); } }); Controller.getEventBus().addHandler(GetSongsForUserEvent.TYPE, new GetSongsForUserEventHandler() { @Override public void handle(Long userId) { setTitleForContentPanel("Playlist - All Songs For User"); Controller.getIntsance().getMainPage().showPlayListInCenter(); Controller.getIntsance().setPlaylistUserId(userId); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.SINGLE_USER); loader.load(); // DeferredCommand.addCommand(new Command() { // // @Override // public void execute() { // // pagingToolBar.enable(); // } // // }); } }); Controller.getEventBus().addHandler(SearchSongsFromAllFriendsPagedEvent.TYPE, new SearchSongsFromAllFriendsPagedEventHandler() { @Override public void handle(Long userId, String searchTerm) { setTitleForContentPanel("Playlist - Song search [" + searchTerm + "]"); MP3PlayerInfo.display("Info", "Now searching for " + searchTerm); Controller.getIntsance().setSearchTerm(searchTerm); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.SEARCH); loader.load(); DeferredCommand.addCommand(new Command() { @Override public void execute() { pagingToolBar.first(); } }); } }); Controller.getEventBus().addHandler(SearchSongsByArtistFromAllFriendsPagedEvent.TYPE, new SearchSongsByArtistFromAllFriendsPagedEventHandler() { @Override public void handle(Long userId, String searchTerm) { MP3PlayerInfo.display("Info", "Now searching for the artist " + searchTerm); setTitleForContentPanel("Playlist - Song search by artist [" + searchTerm + "]"); Controller.getIntsance().setSearchTerm(searchTerm); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.ARIST_SEARCH); loader.load(); DeferredCommand.addCommand(new Command() { @Override public void execute() { pagingToolBar.first(); } }); } }); Controller.getEventBus().addHandler(SearchSongsByAlbumFromAllFriendsPagedEvent.TYPE, new SearchSongsByAlbumFromAllFriendsPagedEventHandler() { @Override public void handle(Long userId, String searchTerm) { setTitleForContentPanel("Playlist - Song search by album [" + searchTerm + "]"); MP3PlayerInfo.display("Info", "Now searching for the album " + searchTerm); Controller.getIntsance().setSearchTerm(searchTerm); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.ALBUM_SEARCH); loader.load(); DeferredCommand.addCommand(new Command() { @Override public void execute() { pagingToolBar.first(); } }); } }); Controller.getEventBus().addHandler(SearchSongsByGenreFromAllFriendsPagedEvent.TYPE, new SearchSongsByGenreFromAllFriendsPagedEventHandler() { @Override public void handle(Long userId, String searchTerm) { MP3PlayerInfo.display("Info", "Now searching for the genre " + searchTerm); setTitleForContentPanel("Playlist - Song search by album [" + searchTerm + "]"); Controller.getIntsance().setSearchTerm(searchTerm); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.GENRE_SEARCH); loader.load(); DeferredCommand.addCommand(new Command() { @Override public void execute() { pagingToolBar.first(); } }); } }); Controller.getEventBus().addHandler(SearchSongsByThisAndSimilarArtistsFromAllFriendsPagedEvent.TYPE, new SearchSongsByThisAndSimilarArtistsFromAllFriendsPagedEventHandler() { @Override public void handle(Long userId, String searchTerm) { MP3PlayerInfo.display("Info", "Now searching for " + searchTerm + " and similar artists."); Controller.getIntsance().setSearchTerm(searchTerm); Controller.getIntsance().setSongRetrievalType(SongRetrievalType.SIMILAR_ARTIST_SEARCH); loader.load(); DeferredCommand.addCommand(new Command() { @Override public void execute() { pagingToolBar.first(); } }); } }); Controller.getEventBus().addHandler(SearchSongsRandomByThisAndSimilarArtistsFromAllFriendsPagedEvent.TYPE, new SearchSongsRandomByThisAndSimilarArtistsFromAllFriendsPagedEventHandler() { @Override public void handle(Long userId, String searchTerm) { MP3PlayerInfo.display("Info", "Creating a playlist for similar artists of " + searchTerm + ""); Controller.getIntsance().setSearchTerm(searchTerm); Controller.getIntsance() .setSongRetrievalType(SongRetrievalType.SIMILAR_ARTIST_SEARCH_RANDOM); loader.load(); DeferredCommand.addCommand(new Command() { @Override public void execute() { Controller.getPlaylistManager().resetPlaylist(); List<SongModelData> playlist = Controller.getPlaylistManager().getPlaylist(); Controller.getPlaylistManager().setPlaylist(playlist, 0); } }); } }); // Legacy shit, this calls arent used anymore // Controller.getEventBuss().addHandler(SearchSongsForUserEvent.TYPE, // new SearchSongsForUserEventHandler(){ // // @Override // public void handle(ArrayList<SongModelData> songs) { // // songsByUserIdStore.removeAll(); // songsByUserIdStore.add(songs); // grid.unmask(); // Controller.getIntsance().ensurePlaylistIsVisible(); // } // // }); // // Controller.getEventBuss().addHandler(SearchSongsFromAllFriendsEvent.TYPE, // new SearchSongsFromAllFriendsEventHandler(){ // // @Override // public void handle(ArrayList<SongModelData> songs) { // // songsByUserIdStore.removeAll(); // songsByUserIdStore.add(songs); // grid.unmask(); // Controller.getIntsance().ensurePlaylistIsVisible(); // } // // }); }
From source file:com.data2semantics.yasgui.client.helpers.AppcacheHelper.java
License:Open Source License
public void getAppcacheSize() { String url = GWT.getModuleBaseURL() + "manifest.appcache?count"; if (JsMethods.isDevPageLoaded()) url += "&type=dev"; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); try {// www .ja v a 2s. c om builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable e) { view.getLogger().severe("Unable to fetch appcache count (does browser support appcache??)"); } @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { setAppcacheSize(response.getText()); } else { view.getLogger().severe("Unable to fetch appcache count (does browser support appcache??)"); } } }); } catch (RequestException e) { //couldnt connect to server view.getLogger().severe("Unable to fetch appcache count (does browser support appcache??)"); } }
From source file:com.data2semantics.yasgui.client.helpers.SparqlQuery.java
License:Open Source License
private void fetchProperties() { //onblur might not always fire (will have to check that). for now, store query in settings before query execution just to be sure view.getCallableJsMethods().storeQueryInCookie(); queryString = view.getSelectedTabSettings().getQueryString(); //the same happens whenever our endpointinput has focus EndpointInput endpointInput = view.getSelectedTab().getEndpointInput(); if (endpointInput != null) { endpointInput.storeEndpointInSettings(); }//www . ja v a 2 s .c o m endpoint = view.getSelectedTabSettings().getEndpoint(); view.checkAndAddEndpointToDs(endpoint); tabId = view.getSelectedTab().getID(); if (view.getSelectedTab().getQueryType().equals("CONSTRUCT") || view.getSelectedTab().getQueryType().equals("DESCRIBE")) { //Change content type automatically for construct queries acceptHeader = view.getSelectedTabSettings().getConstructContentType(); } else { acceptHeader = view.getSelectedTabSettings().getSelectContentType(); } acceptHeader += ",*/*;q=0.9"; customQueryArgs = view.getSelectedTabSettings().getQueryArgs(); queryRequestMethod = (view.getSelectedTabSettings().getRequestMethod().equals("GET") ? RequestBuilder.GET : RequestBuilder.POST); }
From source file:com.data2semantics.yasgui.client.helpers.SparqlQuery.java
License:Open Source License
public void doRequest() { if (!view.getConnHelper().isOnline() && !JsMethods.corsEnabled(endpoint)) { //cors disabled and not online: problem! String errorMsg = "YASGUI is current not connected to the YASGUI server. " + "This mean you can only access endpoints on your own computer (e.g. localhost), which are <a href=\"http://enable-cors.org/\" target=\"_blank\">CORS enabled</a>.<br>" + "The endpoint you try to access is either not running on your computer, or not CORS-enabled.<br>" + corsNotification;//from w w w . j a v a 2 s . c o m view.getErrorHelper().onQueryError(errorMsg, endpoint, queryString, customQueryArgs); return; } view.getElements().onQueryStart(); RequestBuilder builder; HashMultimap<String, String> queryArgs = customQueryArgs; RequestBuilder.Method requestMethod = queryRequestMethod; queryArgs.put("query", queryString); if (JsMethods.corsEnabled(endpoint)) { String params = Helper.getParamsAsString(queryArgs); String url = endpoint; if (queryRequestMethod == RequestBuilder.GET) { url += "?" + params; } builder = new RequestBuilder(queryRequestMethod, url); if (queryRequestMethod == RequestBuilder.POST) { builder.setHeader("Content-Type", "application/x-www-form-urlencoded"); builder.setRequestData(params); } } else { requestMethod = RequestBuilder.POST; queryArgs.put("endpoint", endpoint); queryArgs.put("requestMethod", (queryRequestMethod == RequestBuilder.POST ? "POST" : "GET")); builder = new RequestBuilder(RequestBuilder.POST, GWT.getModuleBaseURL() + "sparql"); //send via proxy builder.setHeader("Content-Type", "application/x-www-form-urlencoded"); } builder.setHeader("Accept", acceptHeader); try { final long startTime = System.currentTimeMillis(); builder.sendRequest((requestMethod == RequestBuilder.POST ? Helper.getParamsAsString(queryArgs) : null), new RequestCallback() { public void onError(Request request, Throwable e) { //e.g. a timeout queryErrorHandler(e); } @Override public void onResponseReceived(Request request, Response response) { view.getElements().onQueryFinish(); if (!response.getStatusText().equals("Abort")) { //if user cancels query, textStatus will be 'abort'. No need to show error window then if (response.getStatusCode() >= 200 && response.getStatusCode() < 300) { if (view.getSettings().useGoogleAnalytics()) { long stopTime = System.currentTimeMillis(); GoogleAnalytics.trackEvent(new GoogleAnalyticsEvent(endpoint, JsMethods.getUncommentedSparql(queryString), Integer.toString((int) (stopTime - startTime)), (int) (stopTime - startTime))); } drawResults(response.getText(), response.getHeader("Content-Type")); } else { queryErrorHandler(response); } } } }); } catch (RequestException e) { queryErrorHandler(e); } }
From source file:com.dawg6.gwt.client.service.ServiceUtil.java
License:Open Source License
public void versionCheck(final Handler<VersionCheck> handler) { Scheduler.get().scheduleDeferred(new Command() { @Override/*from w w w. j av a 2s. c o m*/ public void execute() { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + versionServletUri); // GWT.log("Version URL = " + builder.getUrl()); final VersionCheck result = new VersionCheck(); try { builder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { String text = response.getText(); if (text != null) { if (text.startsWith(VersionBuilder.PREFIX)) { result.serverVersion = text.substring(VersionBuilder.PREFIX.length()); if (text.startsWith(CLIENT_VERSION.getPrefixString())) { result.success = true; } } } if ((!result.success) && (result.serverVersion == null)) { result.exception = "Unable to obtain Server version."; } if (handler != null) handler.handleResult(result); } @Override public void onError(Request request, Throwable exception) { result.success = false; result.exception = "Error communicating with server."; if (handler != null) handler.handleResult(result); } }); } catch (Exception e) { result.success = false; result.exception = "Error communicating with server."; if (handler != null) handler.handleResult(result); } } }); }
From source file:com.dawg6.web.dhcalc.client.Service.java
License:Open Source License
public void versionCheck(final Handler<VersionCheck> handler) { Scheduler.get().scheduleDeferred(new Command() { @Override//ww w.j a va2s . com public void execute() { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "version?v2"); final VersionCheck result = new VersionCheck(); try { builder.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { String text = response.getText(); if (text != null) { if (text.startsWith(Version.PREFIX)) { result.serverVersion = text.substring(Version.PREFIX.length()); if (text.startsWith(Version.getVersion().getPrefixString())) { result.success = true; } } } if ((!result.success) && (result.serverVersion == null)) { result.exception = "Unable to obtain Server version."; } if (handler != null) handler.handleResult(result); } @Override public void onError(Request request, Throwable exception) { result.success = false; result.exception = "Error communicating with server."; if (handler != null) handler.handleResult(result); } }); } catch (Exception e) { result.success = false; result.exception = "Error communicating with server."; if (handler != null) handler.handleResult(result); } } }); }
From source file:com.epam.feel.client.ui.util.gwtupload.FixedUploader.java
License:Apache License
public void update() { try {/*from w w w . j av a2 s. c o m*/ if (waitingForResponse) { return; } waitingForResponse = true; // Using a reusable builder makes IE fail because it caches the response // So it's better to change the request path sending an additional random parameter RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, composeURL("filename=" + fileInput.getName(), "c=" + requestsCounter++)); reqBuilder.setTimeoutMillis(DEFAULT_AJAX_TIMEOUT); reqBuilder.sendRequest("get_status", onStatusReceivedCallback); } catch (RequestException e) { e.printStackTrace(); } }
From source file:com.epam.feel.client.ui.util.gwtupload.FixedUploader.java
License:Apache License
private void sendAjaxRequestToCancelCurrentUpload() throws RequestException { RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, composeURL("cancel=true")); reqBuilder.sendRequest("cancel_upload", onCancelReceivedCallback); }
From source file:com.epam.feel.client.ui.util.gwtupload.FixedUploader.java
License:Apache License
private void sendAjaxRequestToDeleteUploadedFile() throws RequestException { RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, composeURL("remove=" + getInputName())); reqBuilder.sendRequest("remove_file", onDeleteFileCallback); }
From source file:com.epam.feel.client.ui.util.gwtupload.FixedUploader.java
License:Apache License
/** * Sends a request to the server in order to get the blobstore path. When the response with the session comes, it * submits the form.//from w ww.ja v a 2 s . co m */ private void sendAjaxRequestToGetBlobstorePath() throws RequestException { RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, getServletPath());// composeURL("blobstore=true")); reqBuilder.setTimeoutMillis(DEFAULT_AJAX_TIMEOUT); reqBuilder.sendRequest("blobstore", onBlobstoreReceivedCallback); }