org.apache.wicket.protocol.http.RequestUtils Java Examples

The following examples show how to use org.apache.wicket.protocol.http.RequestUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddAnyButton.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBeforeRender() {

    final BookmarkablePageLink link = (BookmarkablePageLink) getWicketSupportFacade().links().newProductLink("link", supplier, product.getProductId());

    final String lang = getLocale().getLanguage();

    final CharSequence uri = link.urlFor(link.getPageClass(), link.getPageParameters());
    final HttpServletRequest req = (HttpServletRequest)((WebRequest) RequestCycle.get().getRequest()).getContainerRequest();
    final String absUri = RequestUtils.toAbsolutePath(req.getRequestURL().toString(), uri.toString());

    final String name = getI18NSupport().getFailoverModel(product.getDisplayName(), product.getName()).getValue(lang);

    final StringBuilder anchor = new StringBuilder()
            .append("<a class=\"a2a_dd\" href=\"http://www.addtoany.com/share_save?linkurl=")
            .append(absUri)
            .append("&amp;linkname=")
            .append(name)
            .append("\">Share</a>");

    final StringBuilder js = new StringBuilder()
            .append("<script type=\"text/javascript\">\n")
            .append("            var a2a_config = a2a_config || {};\n")
            .append("            a2a_config.linkname = \"").append(name).append("\";\n")
            .append("            a2a_config.linkurl = \"").append(absUri).append("\";\n")
            .append("            a2a_config.locale = \"").append(lang).append("\";")
            .append("            a2a_config.color_main = \"D7E5ED\";")
            .append("            a2a_config.color_border = \"AECADB\";")
            .append("            a2a_config.color_link_text = \"333333\";")
            .append("            a2a_config.color_link_text_hover = \"333333\";")
            .append("</script>");

    addOrReplace(new Label("anchor", anchor.toString()).setEscapeModelStrings(false));
    addOrReplace(new Label("js", js.toString()).setEscapeModelStrings(false));

    super.onBeforeRender();
}
 
Example #2
Source File: AbsoluteUrlRequestCodingStrategy.java    From ontopia with Apache License 2.0 5 votes vote down vote up
public static CharSequence toAbsoluteUrl(String url) {
  // make relative links absolute
  if (url.startsWith("../../")) {
    HttpServletRequest req = ((WebRequest)RequestCycle.get().getRequest()).getHttpServletRequest();
    return req.getContextPath() + "/" + url.substring("../../".length());
  } else {
    return RequestUtils.toAbsolutePath(url);
  }
}
 
Example #3
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @param relativePagePath
 * @return
 * @see RequestUtils#toAbsolutePath(String, String)
 * @see URLHelper#removeJSessionId(String)
 */
public final static String toAbsolutePath(final String requestUrl, final String relativePagePath)
{
  final String absoluteUrl = RequestUtils.toAbsolutePath(requestUrl, relativePagePath);
  return URLHelper.removeJSessionId(absoluteUrl);
}