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:es.deusto.weblab.client.HistoryProperties.java

License:Open Source License

public static String encode(String text) {
    String encoded = URL.encode(text);
    encoded = encoded.replace(":", "%3A");
    encoded = encoded.replace("/", "%2F");
    encoded = encoded.replace("#", "%23");
    encoded = encoded.replace("&", "%26");
    encoded = encoded.replace("=", "%3D");
    return encoded;
}

From source file:es.upm.fi.dia.oeg.map4rdf.client.widget.GeoResourceSummary.java

License:Open Source License

public void setGeoResource(final GeoResource resource, Geometry geometry) {
    //TODO Analyze if it is easy to implement closeProperSummary depend on configuration param.
    openOrCloseSummary(false);/*from  w ww. ja v a2 s .co  m*/
    lastGeoResource = resource;
    lastGeometry = geometry;
    centerPanel.clear();
    centerPanel.add(getCenterImage());

    AdditionalInfoExecuter.cancelAllCallbacks();
    AdditionalInfoExecuter.getAdditionalInfo(configID.getConfigID(), dispatchAsync, resource,
            new InfoCallback() {
                @Override
                public void success(AdditionalInfoSummary additionalInfo) {
                    summary.clearAdditionalInfo();
                    additionalsInfo = additionalInfo.getAdditionalInfo();
                    if (additionalInfo.haveImage()) {
                        centerPanel.clear();
                        Image image = new Image(GWT.getModuleBaseURL() + additionalInfo.getImage());
                        image.getElement().getStyle().setCursor(Cursor.POINTER);
                        image.getElement().getStyle().setPosition(Position.ABSOLUTE);
                        image.addClickHandler(new ClickHandler() {
                            @Override
                            public void onClick(ClickEvent event) {
                                close();
                            }
                        });
                        centerPanel.add(image);
                    }
                    summary.addAdditionalInfo(additionalsInfo);
                }
            });
    if (wikipediaResultWidget != null) {
        eventBus.fireEvent(new ResultWidgetRemoveEvent(wikipediaResultWidget));
        wikipediaResultWidget = null;
    }
    if (GeoUtils.getCentroid(geometry) != null) {
        routesWidget.setVisible(true);
        bufferWidget.setVisible(true);
    } else {
        routesWidget.setVisible(false);
        bufferWidget.setVisible(false);
    }
    if (resource.getUri() != null) {
        infoWidget.setVisible(true);
        twitterAnchor.setVisible(true);
        twitterAnchor.setHref(twitterURL + URL.encode(resource.getUri()));
        rdfAnchor.setVisible(true);
        rdfAnchor.setHref(resource.getUri());
        editWidget.setVisible(true);
        statisticsWidget.setVisible(true);
        wikipediaWidget.setVisible(true);
    } else {
        editWidget.setVisible(false);
        twitterAnchor.setVisible(false);
        rdfAnchor.setVisible(false);
        wikipediaWidget.setVisible(false);
        if (geometry.getType() != MapShape.Type.POINT) {
            infoWidget.setVisible(false);
            statisticsWidget.setVisible(false);
        }
    }
    ArrayList<Widget> visibleWidget = new ArrayList<Widget>();
    for (int i = 0; i < allWidgetInOrder.size(); i++) {
        if (allWidgetInOrder.get(i).isVisible()) {
            visibleWidget.add(allWidgetInOrder.get(i));
        }
    }
    summaryMove.cancelMove();
    parametersSummary = initializeParametersSummary(visibleWidget.size(), moveType);
    summary.setGeoResource(resource, geometry);
    summaryMove = new SummaryMove(visibleWidget, parametersSummary, this);
    moveInitialPosition();
    summaryMove.startMoveWidgets();
}

From source file:fast.servicescreen.client.rpc.SendRequestHandler.java

License:Open Source License

/**
 * This method should replace the examplevalues into the inputPort tags.
 * U can give the body String or the get url to replace values!
 * *//*w  w w  . j av a 2s  .co  m*/
@SuppressWarnings("unchecked")
protected String replaceInPorts_byExampleValues(String url_or_body) {
    // insert example values for input port names
    Iterator<FactPort> iteratorOfPreconditions = designer.serviceScreen.iteratorOfPreconditions();
    while (iteratorOfPreconditions.hasNext()) {
        FactPort nextPort = iteratorOfPreconditions.next();
        String exampleValue = nextPort.getExampleValue();
        String portName = nextPort.getName();

        if (exampleValue != null && !exampleValue.equals("") && portName != null && !portName.equals("")) {
            // do expansion
            String encodedValue = URL.encode(exampleValue);
            url_or_body = url_or_body.replaceAll("<<" + portName + ">>", encodedValue);
        }
    }

    return url_or_body;
}

From source file:fi.jyu.student.jatahama.onlineinquirytool.shared.Utils.java

License:Open Source License

public static String getSafeXHTMLAnchor(String id, String cls, String href, String text) {
    String isnull = (text == null ? " ca:isnull=\"true\"" : " ca:isnull=\"false\"");
    String hrefl = "";
    if (href != null) {
        hrefl = " href=\"";
        hrefl += URL.encode(href);
        hrefl += "\"";
    }//from  w w  w  .j a va  2s  .c  o  m
    String str = "<a" + isnull + hrefl + (id != null ? " id=\"" + id + "\"" : "")
            + (cls != null ? " class=\"" + cls + "\"" : "") + ">";
    //str += "<![CDATA["; // xhtml not working in new javascript opened window
    str += text != null ? SafeHtmlUtils.htmlEscape(text) : OnlineInquiryTool.constants.tcTxtChartTextEmpty();
    //str += "]]></pre>"; // xhtml not working in new javascript opened window
    str += "</a>";
    return str;
}

From source file:fr.aliasource.webmail.client.reader.AttachmentDisplay.java

License:GNU General Public License

public AttachmentDisplay(final AttachmentMetadata meta, final String atId) {
    String encodedFilename = URL.encode(meta.getFileName());

    addMimeImage(meta, atId);//from  w w w. j  a  v a2s  .  c o m

    HTML label = new HTML("<b>" + meta.getFileName() + "</b>");
    setWidget(0, 1, label);

    Label size = new Label(prettySize(meta.getSize()));
    setWidget(1, 1, size);

    Anchor view = new Anchor(I18N.strings.viewAttachment(), false, "view/" + atId + "/" + encodedFilename);
    view.getElement().setAttribute("target", "_blank");
    setWidget(1, 2, view);

    Anchor download = new Anchor(I18N.strings.downloadAttachment(), false,
            "download/" + atId + "/" + encodedFilename);
    download.getElement().setAttribute("target", "_blank");
    setWidget(1, 3, download);

    getFlexCellFormatter().setColSpan(0, 1, 4);
    getFlexCellFormatter().setRowSpan(0, 0, 2);
}

From source file:fr.aliasource.webmail.client.reader.ConversationActions.java

License:GNU General Public License

public void notifyConvChanged() {
    Folder f = WebmailController.get().getSelector().getCurrent();
    final Conversation cur = cd.getConversationContent().getConversation();

    HashSet<ConversationId> sel = new HashSet<ConversationId>();
    sel.add(cur.getId());/*from   ww  w.ja  va 2  s  .  com*/
    mam.setSelection(sel);
    ccm.setSelection(sel);
    mcm.setSelection(sel);
    GWT.log("setting selection to " + sel + " (id: " + cur.getId() + ")", null);

    String conversationId = URL.encode(cur.getId().getConversationId());
    String url = "export/conv/" + conversationId + ".html";
    printAll.setHref(url);

    url = "export/conv/" + URL.encode(conversationId) + ".pdf";
    exportAll.setHref(url);

    if (!f.isSearch()) {
        setPrevNextLinkStates();
    } else {
        AjaxCall.search.computePrevNext(f, cur.getId(), new AsyncCallback<Conversation>() {
            public void onFailure(Throwable caught) {
                GWT.log("computePrevNext failure", caught);
                cur.setPrev(null);
                cur.setNext(null);
                setPrevNextLinkStates();
            }

            public void onSuccess(Conversation result) {
                if (result != null) {
                    cur.setPrev(result.getPrev());
                    cur.setNext(result.getNext());
                } else {
                    cur.setPrev(null);
                    cur.setNext(null);
                }
                setPrevNextLinkStates();
            }
        });
    }
}

From source file:fr.aliasource.webmail.client.reader.invitation.GoingEventDataRequest.java

License:GNU General Public License

public void requestGoing(String extId, final String going) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
    builder.setHeader("Content-Type", "application/x-www-form-urlencoded");

    String requestData = "token=" + URL.encodeComponent(token);
    requestData += "&extId=" + URL.encodeComponent(extId);
    requestData += "&going=" + URL.encodeComponent(going);
    try {/*  ww w .  j a  v a2s  .  co  m*/
        builder.sendRequest(requestData, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("srv error", exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    // Process the response in response.getText()
                    String resp = response.getText();
                    GWT.log("text:\n" + resp, null);
                    ctrl.goingReceived(going);
                } else {
                    GWT.log("error: " + response.getStatusCode() + " " + response.getStatusText(), null);
                }
            }
        });
    } catch (RequestException e) {
        // Couldn't connect to server
    }
}

From source file:fr.aliasource.webmail.client.reader.invitation.InvitationInfoDataProvider.java

License:GNU General Public License

public void requestInvitation(MessageId messageId, String folder) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
    builder.setHeader("Content-Type", "application/x-www-form-urlencoded");

    String requestData = "token=" + URL.encodeComponent(token);
    requestData += "&messageId=" + URL.encodeComponent(String.valueOf(messageId.getMessageId()));
    requestData += "&folder=" + URL.encodeComponent(folder);
    try {/*from w w w.  j av a2  s.  c  o m*/
        builder.sendRequest(requestData, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                GWT.log("srv error", exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 == response.getStatusCode()) {
                    // Process the response in response.getText()
                    String resp = response.getText();
                    Document doc = XMLParser.parse(resp);

                    InvitationInfo invitationInfo = parseXml(doc);
                    ctrl.invitationReceived(invitationInfo);
                } else {
                    GWT.log("error: " + response.getStatusCode() + " " + response.getStatusText(), null);
                }
            }

        });
    } catch (RequestException e) {
        GWT.log("Couldn't connect to server", e);
    }
}

From source file:fr.aliasource.webmail.client.reader.MessageMenu.java

License:GNU General Public License

private Anchor getPrint() {
    Anchor ret = new Anchor(I18N.strings.printOne());
    ret.setTarget("_blank");
    String url = "export/conv/" + URL.encode(cm.getConvId() + "|" + cm.getUid()) + ".html";
    ret.setHref(url);// w ww . j a  v  a  2 s  . c  o  m

    ret.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            pp.hide();
            setDown(false);
        }
    });
    return ret;
}

From source file:fr.aliasource.webmail.client.reader.MessageMenu.java

License:GNU General Public License

private Anchor getExport() {
    Anchor ret = new Anchor(I18N.strings.exportOne());
    ret.setTarget("_blank");
    String url = "export/conv/" + URL.encode(cm.getConvId() + "|" + cm.getUid()) + ".pdf";
    ret.setHref(url);/* ww  w .j  a  v  a  2s .c  o m*/

    ret.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            pp.hide();
            setDown(false);
        }
    });
    return ret;
}