Example usage for com.google.gwt.http.client URL encode

List of usage examples for com.google.gwt.http.client URL encode

Introduction

In this page you can find the example usage for com.google.gwt.http.client URL encode.

Prototype

public static String encode(String decodedURL) 

Source Link

Document

Returns a string where all characters that are not valid for a complete URL have been escaped.

Usage

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 va2 s  .co m*/
                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.openid.OpenId.java

License:Open Source License

/**
 * Log out/*from  w w w .  jav a 2 s  . c  om*/
 */
public void logOut() {
    String url;
    url = StaticConfig.OPEN_ID_SERVLET + "?logOut=1&appBaseUrl=" + URL.encode(GWT.getHostPageBaseURL());
    if (!GWT.isProdMode()) {
        url += StaticConfig.DEBUG_FILE + "&" + StaticConfig.DEBUG_ARGUMENT_KEY + "="
                + StaticConfig.DEBUG_ARGUMENT_VALUE;
    }
    Window.Location.assign(url);
    loggedIn = false;
}

From source file:com.dawg6.web.dhcalc.client.ClientUtils.java

License:Open Source License

public static String getProfileUrl(DpsTableEntry entry) {

    StringBuffer buf = new StringBuffer();

    buf.append(entry.getRealm().getHost());
    buf.append("/d3/profile/");

    String[] split = entry.getBattletag().split("/");

    try {//from  www.  j av  a  2 s .c  om
        buf.append(URL.encode(split[0]));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    buf.append("/hero/" + split[1]);

    return buf.toString();
}

From source file:com.dawg6.web.dhcalc.client.MainPanel.java

License:Open Source License

protected void showProfile() {
    Realm realm = getSelectedRealm();//from   w  ww.  ja  v  a  2  s. co  m

    final String server = realm.getHost();

    if ((battleTag.getText() == null) || (battleTag.getText().trim().length() == 0)) {
        ApplicationPanel.showErrorDialog("Enter Battle Tag");
        return;
    }

    final String profile = battleTag.getText();

    if ((tagNumber.getValue() == null) || (tagNumber.getValue().trim().length() == 0)) {
        ApplicationPanel.showErrorDialog("Enter Battle Tag Number");
        return;
    }

    int tag = (int) getValue(this.tagNumber);

    String url = server + "/d3/profile/" + URL.encode(profile) + "-" + tag + "/";

    int index = heroList.getSelectedIndex();

    if (index >= 0) {

        String value = heroList.getValue(index);

        if (value.length() > 0) {
            url += ("hero/" + value);
        }
    }

    Window.open(url, "_blank", "");

}

From source file:com.ephesoft.dcma.gwt.foldermanager.client.view.widget.FolderUploadWidget.java

License:Open Source License

protected void setAndStartUpload(String uploadFormAction, String absolutePath) {
    StringBuffer urlBuffer = new StringBuffer(uploadFormAction);
    if (Window.Location.getHref().contains(FolderManagementConstants.QUESTION_MARK)) {
        urlBuffer.append(FolderManagementConstants.AMPERSAND);
    } else {/*from w  w  w  .j a  v  a  2 s.c  o m*/
        urlBuffer.append(FolderManagementConstants.QUESTION_MARK);
    }
    urlBuffer.append(FolderManagementConstants.CURRENT_UPLOAD_FOLDER_NAME);
    urlBuffer.append(FolderManagementConstants.EQUALS);
    urlBuffer.append(URL.encode(absolutePath));
    swfUpload.setUploadURL(urlBuffer.toString());
    swfUpload.startUpload();
}

From source file:com.feller.picup.client.PickUp.java

License:Open Source License

protected void getBucketURL() {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(getBacketURL));

    try {/* www  . j  a  v  a  2  s .  co  m*/
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                displayError("Couldn't retrieve JSON ::" + exception.getMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {

                    urlToQR(response.getText());
                } else {
                    displayError("couldn't retrieve JSON (" + response.getStatusCode() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("exception: Couldn't retrieve JSON" + e.getMessage());
    }

}

From source file:com.google.caliper.cloud.client.BenchmarkDataViewer.java

License:Apache License

private void rebuildSnapshotDisclaimer() {
    snapshotDisclaimerDiv.clear();/*from   w  ww . j a va 2 s  . c  o m*/
    if (isSnapshot()) {
        DateTimeFormat format = DateTimeFormat.getFormat("yyyy-MM-dd 'at' HH:mm:ss Z");
        long createdEpochTime = 0;
        for (BenchmarkSnapshotMeta snapshot : benchmarkMeta.getSnapshots()) {
            if (snapshot.getId() == snapshotId) {
                createdEpochTime = snapshot.getCreated();
            }
        }
        String formattedDate = format.format(new Date(createdEpochTime));
        snapshotDisclaimerDiv.add(
                new HTML("This is a snapshot taken on " + formattedDate + " (<a target=\"_blank\" href=\"/run/"
                        + URL.encode(benchmarkOwner) + "/" + URL.encode(benchmarkName) + "\">Original</a>)"));
    }
}

From source file:com.google.gwt.sample.client.mystockwatcherEntryPoint.java

/**
 * Generate random stock prices./*  w ww .j  a v  a 2 s  .  c  o m*/
 */
private void refreshWatchList() {
    if (stocks.size() == 0) {
        return;
    }

    String url = JSON_URL;

    // Append watch list stock symbols to query URL.
    Iterator iter = stocks.iterator();
    while (iter.hasNext()) {
        url += iter.next();
        if (iter.hasNext()) {
            url += "+";
        }
    }

    url = URL.encode(url);

    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

    try {
        Request request = builder.sendRequest(null, new RequestCallback() {

            @Override
            public void onError(Request request, Throwable exception) {
                displayError("Couldn't retrieve JSON");
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    updateTable(asArrayOfStockData(response.getText()));
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("Couldn't retrieve JSON");
    }
}

From source file:com.google.gwt.sample.stockwatcher.client.PetrolTracker.java

/**
 * Add stock to FlexTable. Executed when the user clicks the addStockButton or
 * presses enter in the newSymbolTextBox.
         //from   w ww. jav  a 2 s  .  c  o m
private void addFillups() {
  final String symbol = newSymbolTextBox.getText().toUpperCase().trim();
  newSymbolTextBox.setFocus(true);
        
  // Stock code must be between 1 and 10 chars that are numbers, letters, or dots.
  if (!symbol.matches("^[0-9a-zA-Z\\.]{1,10}$")) {
    Window.alert("'" + symbol + "' is not a valid symbol.");
    newSymbolTextBox.selectAll();
    return;
  }
        
  newSymbolTextBox.setText("");
        
  // Don't add the stock if it's already in the table.
  if (stocks.contains(symbol))
    return;
        
  // Add the stock to the table.
  int row = fillupFlexTable.getRowCount();
  stocks.add(symbol);
  fillupFlexTable.setText(row, 0, symbol);
  fillupFlexTable.setWidget(row, 2, new Label());
  fillupFlexTable.getCellFormatter().addStyleName(row, 1, "watchListNumericColumn");
  fillupFlexTable.getCellFormatter().addStyleName(row, 2, "watchListNumericColumn");
  fillupFlexTable.getCellFormatter().addStyleName(row, 3, "watchListRemoveColumn");
        
  // Add a button to remove this stock from the table.
  Button removeStockButton = new Button("x");
  removeStockButton.addStyleDependentName("remove");
  removeStockButton.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
int removedIndex = stocks.indexOf(symbol);
stocks.remove(removedIndex);
fillupFlexTable.removeRow(removedIndex + 1);
    }
  });
  fillupFlexTable.setWidget(row, 3, removeStockButton);
        
  // Get the stock price.
  refreshWatchList();
        
}
*/
private void refreshFillups() {
    String url = JSON_URL;

    final String encodedUrl = URL.encode(url);
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, encodedUrl);
    try {
        @SuppressWarnings("unused")
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                displayError("Couldn't retrieve JSON on url:" + encodedUrl);
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    String jsonString = response.getText();
                    updateTable(asArrayOfFillupData(jsonString));
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("Couldn't retrieve JSON");
    }

}

From source file:com.google.gwt.sample.stockwatcher.client.ui.StockWatcherViewImpl.java

/**
 * Generate random stock prices.//from   w  w w .  j av  a  2s .c o  m
 */
private void refreshWatchList() {
    if (stocks.size() == 0) {
        return;
    }
    String url = JSON_URL;

    // Append watch list stock symbols to query URL.
    Iterator iter = stocks.iterator();
    while (iter.hasNext()) {
        url += iter.next();
        if (iter.hasNext()) {
            url += "+";
        }
    }

    url = URL.encode(url);

    // Send request to server and catch any errors.
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

    try {
        Request request = builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                displayError("Couldn't retrieve JSON");
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    updateTable(asArrayOfStockData(response.getText()));
                } else {
                    displayError("Couldn't retrieve JSON (" + response.getStatusText() + ")");
                }
            }
        });
    } catch (RequestException e) {
        displayError("Couldn't retrieve JSON");
    }
}