@Override public String encodeURL(CharSequence url) { if (original != null) { return original.encodeURL(url); } else { return url != null ? url.toString() : null; } }
@Override public String encodeURL(CharSequence url) { if (original != null) { return original.encodeURL(url); } else { return url != null ? url.toString() : null; } }
@Override public String encode(final String url) { String[] elements = StringUtils.split(url, '/'); for (int i = 0; i < elements.length; i++) { elements[i] = org.apache.wicket.util.encoding.UrlEncoder.PATH_INSTANCE.encode(elements[i], "UTF-8"); } final String encodedUrl = StringUtils.join(elements, '/'); RequestCycle requestCycle = RequestCycle.get(); return requestCycle != null ? requestCycle.getResponse().encodeURL(encodedUrl).toString() : encodedUrl; } }
/** * Should be c:url equivalent, but isn't yet (works for now). * * @param requestCycle Needed to encode url. * @param path * @param encodeUrl * @return path itself if not starts with '/' otherwise "/ProjectForge" + path with session id and params. */ public static String getUrl(final RequestCycle requestCycle, final String path, final boolean encodeUrl) { String url = UrlUtils.rewriteToContextRelative(path, requestCycle); if (encodeUrl == true) { url = requestCycle.getResponse().encodeURL(url); } return url; }
/** * Create image xml tag which represets image html tag with proper url generated. * * @param pImageFileDescription * - image file description. * @param pUrl * - component url. * @return image xml tag which represets image html tag with proper url generated. */ public static XmlTag createImageTag(ImageFileDescription pImageFileDescription, CharSequence pUrl) { XmlTag tag = new XmlTag(); tag.setName("img"); tag.setType(XmlTag.TagType.OPEN_CLOSE); tag.put(IMAGE_FILE_NAME, pImageFileDescription.getName()); StringBuilder sb = new StringBuilder(pUrl); sb.append("&").append(IMAGE_FILE_NAME).append("=").append(pImageFileDescription.getName()); sb.append("&") .append(IMAGE_CONTENT_TYPE) .append("=") .append(pImageFileDescription.getContentType()); tag.put( "src", RequestCycle.get() .getOriginalResponse() .encodeURL(sb.toString())); return tag; } }
/** * Create image xml tag which represets image html tag with proper url generated. * * @param pImageFileDescription * - image file description. * @param pUrl * - component url. * @return image xml tag which represets image html tag with proper url generated. */ public static XmlTag createImageTag(ImageFileDescription pImageFileDescription, CharSequence pUrl) { XmlTag tag = new XmlTag(); tag.setName("img"); tag.setType(XmlTag.TagType.OPEN_CLOSE); tag.put(IMAGE_FILE_NAME, pImageFileDescription.getName()); StringBuilder sb = new StringBuilder(pUrl); sb.append("&").append(IMAGE_FILE_NAME).append("=").append(pImageFileDescription.getName()); sb.append("&") .append(IMAGE_CONTENT_TYPE) .append("=") .append(pImageFileDescription.getContentType()); tag.put( "src", RequestCycle.get() .getOriginalResponse() .encodeURL(sb.toString())); return tag; } }
/** * Create image xml tag which represets image html tag with proper url generated. * * @param pImageFileDescription * - image file description. * @param pUrl * - component url. * @return image xml tag which represets image html tag with proper url generated. */ public static XmlTag createImageTag(ImageFileDescription pImageFileDescription, CharSequence pUrl) { XmlTag tag = new XmlTag(); tag.setName("img"); tag.setType(XmlTag.TagType.OPEN_CLOSE); tag.put(IMAGE_FILE_NAME, pImageFileDescription.getName()); StringBuilder sb = new StringBuilder(pUrl); sb.append("&").append(IMAGE_FILE_NAME).append("=").append(pImageFileDescription.getName()); sb.append("&") .append(IMAGE_CONTENT_TYPE) .append("=") .append(pImageFileDescription.getContentType()); tag.put( "src", RequestCycle.get() .getOriginalResponse() .encodeURL(sb.toString())); return tag; } }
protected String getChannelIconUrl(final Map<String, String> channelFieldValues, final String channelIconPathTemplate) { String channelIconPath = new MapVariableInterpolator(channelIconPathTemplate, channelFieldValues).toString(); if (StringUtils.isEmpty(channelIconPath)) { return null; } RequestCycle requestCycle = RequestCycle.get(); if (requestCycle != null) { javax.jcr.Session session = UserSession.get().getJcrSession(); try { if (session.nodeExists(channelIconPath)) { String url = encodeUrl("binaries" + channelIconPath); return requestCycle.getResponse().encodeURL(url); } } catch (RepositoryException repositoryException) { log.error("Error getting the channel icon resource url.", repositoryException); } } return null; }
/** * Renders a javascript component to create the player. */ @Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { super.onComponentTagBody(markupStream, openTag); replaceComponentTagBody(markupStream, openTag, null); JavaScriptUtils.writeJavaScript(getResponse(), "new eidogo.Player({container:\"" + getMarkupId() + "\",theme:\"" + theme + "\"," + "sgfUrl:\"" + getResponse().encodeURL(sgfUrl) + "\"," + "loadPath:[0, 0]" + ",mode:\"" + mode + "\"," + "showComments:" + showComments + "," + "showPlayerInfo:" + showPlayerInfo + "," + "showGameInfo:" + showGameInfo + "," + "showTools:" + showTools + "," + "showOptions:" + showOptions + "," + "markCurrent:" + markCurrent + "," + "markVariations:" + markVariation + "," + "markNext:" + markNext + "," + "enableShortcuts:" + enableShortcuts + "," + "problemMode:" + problemMode + "});"); }
/** * Get the absolute bookmarkable path of a page * * @param pageClass Page * @param pageParameters Optional page parameters * @return Bookmarkable path */ public static String absoluteMountPathForPage(Class<? extends Page> pageClass, PageParameters pageParameters) { HttpServletRequest req = getHttpServletRequest(); RequestCycle requestCycle = RequestCycle.get(); Url url = requestCycle.mapUrlFor(pageClass, pageParameters); String renderedUrl = url.toString(); renderedUrl = Strings.isEmpty(renderedUrl) ? "." : renderedUrl; return RequestUtils.toAbsolutePath(HttpUtils.getWebappContextUrl(req), requestCycle.getOriginalResponse().encodeURL(renderedUrl)); }