List of usage examples for com.google.gwt.http.client URL decodeQueryString
public static String decodeQueryString(String encodedURLComponent)
From source file:bufferings.ktr.wjr.client.WjrPresenter.java
License:Apache License
/** * Builds the not immutable map from String to List<String> that we'll return * in getParameterMap().//from w w w. j a v a2 s . co m * * @return a map from the queryString. * @see Window.Location#buildListParamMap(String) */ protected Map<String, List<String>> buildListParamMap(String queryString) { Map<String, List<String>> out = new HashMap<String, List<String>>(); if (queryString != null && queryString.length() > 1) { String qs = queryString.substring(1); for (String kvPair : qs.split("&")) { String[] kv = kvPair.split("=", 2); if (kv[0].length() == 0) { continue; } List<String> values = out.get(kv[0]); if (values == null) { values = new ArrayList<String>(); out.put(kv[0], values); } values.add(kv.length > 1 ? URL.decodeQueryString(kv[1]) : ""); } } return out; }
From source file:cc.alcina.framework.gwt.client.provider.ClientURLComponentEncoder.java
License:Apache License
public String decode(String componentText) { return URL.decodeQueryString(componentText); }
From source file:com.agnie.common.gwt.serverclient.client.helper.URLInfoImpl.java
License:Open Source License
@Override public String decodeUTF8URL(String encodedUrl) { return URL.decodeQueryString(encodedUrl); }
From source file:com.dreamskiale.client.history.CustomHistorian.java
License:Apache License
/** * This method is responsible for reading the browser url and converting it into a token that GWT Places can use. * /*from w ww. j a v a 2 s .c om*/ * The token must be in the format of "prefix:value" * * value must be url decoded */ @Override public final String getToken() { String path = getWindowLocationPath(); String hash = getWindowLocationHash(); if (!isBlank(hash)) { String hashSeparator = "#" + getUrlSeparator(); if (hash.startsWith(hashSeparator)) { hash = hash.substring(hashSeparator.length()); } else { // Doesn't start with a hash bang, it's an invalid url return ""; } } String gwtPlaceToken = fromPathToToken(getPath(path, hash)); // in here we should have "prefix:value" // ensure value is url decoded if (!isBlank(gwtPlaceToken) && !gwtPlaceToken.equals(":")) { String[] s = gwtPlaceToken.split(":"); return s[0] + ":" + (s.length == 2 ? URL.decodeQueryString(s[1]) : ""); } else { return ""; } }
From source file:com.edgenius.wiki.gwt.client.GwtClientUtils.java
License:Open Source License
/** * @return//w w w .j a v a 2 s.c o m */ public static String getToken() { //page#/xxx - xxx must do URLEncode otherwise it will broken URL even its value in anchor part //I found FF looks OK if there is no this decode, but Chrome does work. Anyway, it is safe to decode here and no side-effect. return URL.decodeQueryString(History.getToken()); }
From source file:com.edgenius.wiki.gwt.client.page.PageMain.java
License:Open Source License
/** * //ww w .j av a2 s. c o m * Monitoring all HyperLink click */ public void onValueChange(ValueChangeEvent<String> event) { String token = event.getValue(); //page#/xxx - xxx must do URLEncode otherwise it will broken URL even its value in anchor part //I found FF looks OK if there is no this decode, but Chrome does work. Anyway, it is safe to decode here and no side-effect. token = URL.decodeQueryString(token); Log.info("Page onHistoryChanged event for " + token); //show loading page first - this is give a change to stop switch panel, useful if editing page is dirty, user clicks nav bar or //page tree item to switch to view another page accident. if (!loading()) return; if (token == null || token.trim().length() == 0) { //dashboard is pure URL like: /page# dashboardPanel.showPanel(); return; } token = token.trim(); //clean attachment panel for new page //broadcast event to all attachment panel - for example, the attachment panel in editPanel and viewPanel resetAttachmentPanel(); String[] tokens = GwtUtils.parseToken(token); Log.info("Parsed tokens:" + Arrays.toString(tokens)); //just try to set a value to spaceUname - it is either second parameter(first is action identifier) in URL or set to default //the exception is view page - spaceUname is first parameter, - customised page(no spaceUname) String spaceUname = GwtUtils.getToken(tokens, 1); if ("".equals(spaceUname)) { spaceUname = getSpaceUname(); Log.info("Set potential spaceUname: " + spaceUname); } String actionID = tokens[0].toUpperCase(); //don't use action check startsWith() as pageTitle could be something link Defined TOKEN, such as $CPAGE etc. //token string is safe as it is unescaped if (!(token.startsWith("/") ? token.startsWith("/$") : token.startsWith("$")) || TOKEN_COMMENT.equals(actionID)) { String pageTitle; String cid = null; if (TOKEN_COMMENT.equals(actionID)) { //goto special comment of this page: /page#/$COMMNET/spaceUname/pageTitle/commnentUid //try to remove anchor from whole page title if it has pageTitle = GwtUtils.getToken(tokens, 2); cid = GwtUtils.getToken(tokens, 3); } else { //view page token: /page#/spaceUname/pageTtitle spaceUname = GwtUtils.getToken(tokens, 0); //try to remove anchor from whole page title if it has pageTitle = GwtUtils.getToken(tokens, 1); } //viewPanel async success method will call "showPanel()" PageControllerAsync action = ControllerFactory.getPageController(); action.viewPage(spaceUname, pageTitle, cid, viewPanel); } else if (TOKEN_CLINK.equals(actionID)) { //get customised link action: /page#/$CL/spaceUname/cLinkToken String params = GwtUtils.getToken(tokens, 2); PluginControllerAsync action = ControllerFactory.getPluginController(); action.invokeLink(spaceUname, params, viewPanel); } else if (TOKEN_CREATE_HOME.equals(actionID) || TOKEN_CREATE.equals(actionID)) { //create page: /page#/$CREATE[$CHOME]/spaceUname/newPageTitle int newPageType; if (TOKEN_CREATE_HOME.equals(actionID)) { newPageType = PageAttribute.NEW_HOMEPAGE; } else { newPageType = PageAttribute.NEW_PAGE; } String newTitle = GwtUtils.getToken(tokens, 2); //comment: don't directly jump to EditPanel although it save server loading //the reason does not switch to EditPanel directly even in create mode: //if user refresh page, for this token, it may lose navigation bar information. PageControllerAsync action = ControllerFactory.getPageController(); this.setPreviewReady(false, null); action.createPage(spaceUname, newTitle, getPageUuid(), newPageType, editPanel); } else if (actionID.endsWith(TOKEN_EDIT)) { //Edit URL: /page#/$EDIT/spaceUname/pageUuid (It is not pageTitle here!) //edit page, need loading content, show loading panel first, String uuid = GwtUtils.getToken(tokens, 2); PageControllerAsync action = ControllerFactory.getPageController(); //after loaded, setPreviewReady(true); this.setPreviewReady(false, null); action.editPage(spaceUname, uuid, editPanel); } else if (actionID.endsWith(TOKEN_EDIT_TEMPLATE)) { //Edit template URL: /page#/$ET/spaceUname/templateUid int templID = NumberUtil.toInt(GwtUtils.getToken(tokens, 2), -1); TemplateControllerAsync action = ControllerFactory.getTemplateController(); if (templID == -1) { //create action.createTemplate(spaceUname, editTemplatePanel); } else { //edit action.editTemplate(spaceUname, templID, editTemplatePanel); } } else if (actionID.endsWith(TOKEN_EDIT_SIDEBAR)) { //Edit sidebar URL: /page#/$ES/spaceUname/sidebarUuid //edit page sidebar, need loading page content(at least pageUuid, in order to return), show loading panel first, String uuid = GwtUtils.getToken(tokens, 2); PageControllerAsync action = ControllerFactory.getPageController(); action.editPageSidebar(spaceUname, uuid, editSidebarPanel); } else if (actionID.endsWith(TOKEN_HISTORY)) { //View history URL: /page#/$HISTORY/spaceUname/historyUid Integer historyUid = Integer.valueOf(GwtUtils.getToken(tokens, 2)); PageControllerAsync action = ControllerFactory.getPageController(); //don't get attachment information action.getHistoryByUid(historyUid, false, viewPanel); } else if (actionID.endsWith(TOKEN_DIFF)) { //View 2 page diff: /page#/$DIFF/historyUid1/historyUid2 Integer historyUid1 = Integer.valueOf(GwtUtils.getToken(tokens, 1)); Integer historyUid2 = Integer.valueOf(GwtUtils.getToken(tokens, 2)); PageControllerAsync action = ControllerFactory.getPageController(); action.diff(historyUid1, historyUid2, viewPanel.versionAsync); } else if (actionID.indexOf(TOKEN_DRAFT) != -1) { //Edit draft URL: /page#/$DRAFT/spaceUname/draftType/draftUid PageType draftType = PageType.fromOrdial(Integer.valueOf(GwtUtils.getToken(tokens, 2))); Integer draftPageUid = Integer.valueOf(GwtUtils.getToken(tokens, 3)); PageControllerAsync action = ControllerFactory.getPageController(); this.setPreviewReady(false, null); action.editDraft(draftPageUid, draftType, true, editPanel); } else if (actionID.indexOf(TOKEN_CPAGE) != -1) { //customised pages URL: /page#/$CPAGE/cpageUID/parameters... String cid = GwtUtils.getToken(tokens, 1); String[] params = null; if (tokens.length > 2) { params = new String[tokens.length - 2]; for (int idx = 0; idx < tokens.length - 2; idx++) { params[idx] = tokens[idx + 2]; } } PageControllerAsync action = ControllerFactory.getPageController(); action.getCustomizedPage(cid, params, viewPanel); } }
From source file:com.google.gerrit.client.admin.GroupListScreen.java
License:Apache License
public GroupListScreen(String params) { for (String kvPair : params.split("[,;&]")) { String[] kv = kvPair.split("=", 2); if (kv.length != 2 || kv[0].isEmpty()) { continue; }/*ww w . j a va 2 s. c o m*/ if ("filter".equals(kv[0])) { subname = URL.decodeQueryString(kv[1]); } } }
From source file:com.google.gerrit.client.admin.PaginatedProjectScreen.java
License:Apache License
protected void parseToken(String token) { for (String kvPair : token.split("[,;&/?]")) { String[] kv = kvPair.split("=", 2); if (kv.length != 2 || kv[0].isEmpty()) { continue; }// w w w. j a va 2 s . c om if ("filter".equals(kv[0])) { match = URL.decodeQueryString(kv[1]); } if ("skip".equals(kv[0]) && URL.decodeQueryString(kv[1]).matches("^[\\d]+")) { start = Integer.parseInt(URL.decodeQueryString(kv[1])); } } }
From source file:com.google.gerrit.client.admin.ProjectListScreen.java
License:Apache License
public ProjectListScreen(String params) { for (String kvPair : params.split("[,;&]")) { String[] kv = kvPair.split("=", 2); if (kv.length != 2 || kv[0].isEmpty()) { continue; }// w w w . j av a 2s. c o m if ("filter".equals(kv[0])) { subname = URL.decodeQueryString(kv[1]); } } }
From source file:com.google.gerrit.client.changes.CustomDashboardScreen.java
License:Apache License
public CustomDashboardScreen(String params) { titles = new ArrayList<String>(); queries = new ArrayList<String>(); for (String kvPair : params.split("[,;&]")) { String[] kv = kvPair.split("=", 2); if (kv.length != 2 || kv[0].isEmpty()) { continue; }//from w ww . ja v a2 s. c o m if ("title".equals(kv[0])) { title = URL.decodeQueryString(kv[1]); } else { titles.add(URL.decodeQueryString(kv[0])); queries.add(URL.decodeQueryString(kv[1])); } } }