List of usage examples for org.apache.wicket.util.string Strings replaceAll
public static CharSequence replaceAll(final CharSequence s, final CharSequence searchFor, CharSequence replaceWith)
From source file:com.doculibre.constellio.wicket.components.modal.NonAjaxModalWindow.java
License:Apache License
/** * Replaces all occurrences of " in string with \". * /*from www . ja v a 2 s . co m*/ * @param string * String to be escaped. * * @return escaped string */ private String escapeQuotes(String string) { if (string.indexOf('"') != -1) { string = Strings.replaceAll(string, "\"", "\\\"").toString(); } return string; }
From source file:com.google.code.jqwicket.DemoPage.java
License:Apache License
protected String getHtmlSourceUrl() { return "/" + Strings.replaceAll(this.getClass().getName(), ".", "/") + ".html"; }
From source file:com.google.code.jqwicket.DemoPage.java
License:Apache License
protected String getJavaSourceUrl() { return "/" + Strings.replaceAll(this.getClass().getName(), ".", "/") + ".java"; }
From source file:com.mylab.wicket.jpa.ui.pages.select2.AbstractSelect2Choice.java
License:Apache License
/** * Escapes single quotes in localized strings to be used as JavaScript strings enclosed in * single quotes// w w w. j av a2s . co m * * @param key * resource key for localized message * @return localized string with escaped single quotes */ protected String getEscapedJsString(String key) { String value = getString(key); return Strings.replaceAll(value, "'", "\\'").toString(); }
From source file:com.senacor.wbs.web.core.ResourceInlineFrame.java
License:Apache License
/** * Handles this frame's tag.// w ww .jav a 2 s . c om * * @param tag * the component tag * @see org.apache.wicket.Component#onComponentTag(ComponentTag) */ protected final void onComponentTag(final ComponentTag tag) { checkComponentTag(tag, "iframe"); // Set href to link to this frame's frameRequested // method CharSequence url = getURL(); // generate the src attribute tag.put("src", Strings.replaceAll(url, "&", "&")); super.onComponentTag(tag); }
From source file:com.servoy.j2db.server.headlessclient.dataui.StripHTMLTagsConverter.java
License:Open Source License
@SuppressWarnings("nls") public static CharSequence convertBlobLoaderReferences(CharSequence text, Component component) { if (text != null) { String txt = text.toString(); int index = txt.indexOf("media:///servoy_blobloader?"); if (index == -1) return txt; ICrypt urlCrypt = null;/*from w ww . j a v a2 s.c o m*/ if (Application.exists()) urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt(); if (urlCrypt != null) { while (index != -1) { // just try to search for the ending quote int index2 = Utils.firstIndexOf(txt, new char[] { '\'', '"', ' ', '\t', ')' }, index); // if ending can't be resolved don't encrypt it. if (index2 == -1) return Strings.replaceAll(text, "media:///servoy_blobloader?", RequestCycle.get().urlFor(component, IResourceListener.INTERFACE) + "&" + BLOB_LOADER_PARAM + "=true&"); String bloburl = generateBlobloaderUrl(component, urlCrypt, txt.substring(index + "media:///".length(), index2)); txt = txt.substring(0, index) + bloburl + txt.substring(index2); index = txt.indexOf("media:///servoy_blobloader?", index + 1); } return txt; } } if (RequestCycle.get() != null) return Strings.replaceAll(text, "media:///servoy_blobloader?", RequestCycle.get().urlFor(component, IResourceListener.INTERFACE) + "&" + BLOB_LOADER_PARAM + "=true&"); return text; }
From source file:com.servoy.j2db.server.headlessclient.dataui.StripHTMLTagsConverter.java
License:Open Source License
public static CharSequence convertMediaReferences(CharSequence text, String solutionName, ResourceReference media, String prefix, boolean quoteSpecialHTMLChars) // TODO quoteSpecialHTMLChars - shouldn't this always be true? (currently in most places it is false) { if (RequestCycle.get() != null) return Strings.replaceAll(text, "media:///", prefix + RequestCycle.get().urlFor(media) + "?s=" //$NON-NLS-1$//$NON-NLS-2$ + solutionName + (quoteSpecialHTMLChars ? "&" : "&") + "id="); //$NON-NLS-1$ return text;//from ww w. j a va2 s . co m }
From source file:com.servoy.j2db.server.headlessclient.dataui.WebBaseButton.java
License:Open Source License
public static Object[] getImageDisplayURL(IImageDisplay imageDisplay, boolean appendRandomParam) { String imgURL = null;/*from w w w . j av a 2s .com*/ Boolean isRandomParamRemoved = Boolean.FALSE; if (imageDisplay instanceof Component) { MediaResource mr; Component imageDisplayComponent = (Component) imageDisplay; if ((mr = imageDisplay.getIcon()) != null) { CharSequence url = imageDisplayComponent.urlFor(ILatestVersionResourceListener.INTERFACE); if (appendRandomParam) { byte[] imageRawData = mr.getRawData(); Checksum checksum = new CRC32(); checksum.update(imageRawData, 0, imageRawData.length); url = url + "&r=" + checksum.getValue(); //$NON-NLS-1$ } else isRandomParamRemoved = Boolean.TRUE; imgURL = Strings.replaceAll(imageDisplayComponent.getResponse().encodeURL(url), "&", "&") //$NON-NLS-1$//$NON-NLS-2$ .toString(); if (imageDisplay.getMediaOptions() != 0 && imageDisplay.getMediaOptions() != 1) { imgURL = imgURL + "&option=" + imageDisplay.getMediaOptions() + "&w=" //$NON-NLS-1$//$NON-NLS-2$ + imageDisplay.getWebBounds().width + "&h=" + //$NON-NLS-1$ imageDisplay.getWebBounds().height; } } else if (imageDisplay.getIconReference() != null && imageDisplay.getMedia() != null) { String solutionName = J2DBGlobals.getServiceProvider().getSolution().getName(); if (imageDisplay.getMediaOptions() != 0 && imageDisplay.getMediaOptions() != 1) { imgURL = imageDisplayComponent.urlFor(imageDisplay.getIconReference()) + "?id=" //$NON-NLS-1$ + imageDisplay.getMedia().getName() + "&s=" + solutionName + //$NON-NLS-1$ "&option=" + //$NON-NLS-1$ imageDisplay.getMediaOptions() + "&w=" + imageDisplay.getWebBounds().width + "&h=" //$NON-NLS-1$//$NON-NLS-2$ + imageDisplay.getWebBounds().height + "&l=" + //$NON-NLS-1$ (imageDisplay.getMedia().getMediaData() != null ? +imageDisplay.getMedia().getMediaData().hashCode() : 0); } else { imgURL = imageDisplayComponent.urlFor(imageDisplay.getIconReference()) + "?id=" //$NON-NLS-1$ + imageDisplay.getMedia().getName() + "&s=" + solutionName + //$NON-NLS-1$ "&l=" //$NON-NLS-1$ + (imageDisplay.getMedia().getMediaData() != null ? +imageDisplay.getMedia().getMediaData().hashCode() : 0); } } else if (imageDisplay.getIconUrl() != null) { imgURL = imageDisplay.getIconUrl(); } else if (imageDisplay.getTextUrl() != null) { String mediaName = imageDisplay.getTextUrl() .substring(MediaURLStreamHandler.MEDIA_URL_DEF.length()); if (mediaName.startsWith(MediaURLStreamHandler.MEDIA_URL_BLOBLOADER)) { ICrypt urlCrypt = null; if (Application.exists()) urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt(); imgURL = StripHTMLTagsConverter.generateBlobloaderUrl(imageDisplayComponent, urlCrypt, mediaName); } } else if (imageDisplay.getRolloverIconReference() != null || imageDisplay.getRolloverUrl() != null || imageDisplay.getRolloverMedia() != null) { imgURL = imageDisplayComponent.urlFor(TRANSPARENT_IMAGE).toString(); } } return new Object[] { imgURL, isRandomParamRemoved }; }
From source file:com.userweave.components.authorization.AuthOnlyCheckBox.java
License:Open Source License
/** * Processes the component tag.// w w w.ja v a 2s . c om * * @param tag * Tag to modify * @see org.apache.wicket.Component#onComponentTag(ComponentTag) */ @Override protected void onComponentTag(final ComponentTag tag) { PackageResourceReference img; if (!isAuthorized) { tag.setName("img"); final String value = getValue(); if (value != null && value.equals("true")) { img = new PackageResourceReference(AuthOnlyCheckBox.class, "res/check.png"); } else { img = new PackageResourceReference(AuthOnlyCheckBox.class, "res/uncheck.png"); } CharSequence url = RequestCycle.get().urlFor(img, null); tag.put("src", RequestCycle.get().getOriginalResponse().encodeURL(Strings.replaceAll(url, "&", "&"))); } else { checkComponentTag(tag, "input"); checkComponentTagAttribute(tag, "type", "checkbox"); final String value = getValue(); if (value != null) { try { if (Strings.isTrue(value)) { tag.put("checked", "checked"); } else { // In case the attribute was added at design time tag.remove("checked"); } } catch (StringValueConversionException e) { throw new WicketRuntimeException("Invalid boolean value \"" + value + "\"", e); } } // Should a roundtrip be made (have onSelectionChanged called) when the // checkbox is clicked? if (wantOnSelectionChangedNotifications()) { // CharSequence url = urlFor(IOnChangeListener.INTERFACE); // // Form form = findParent(Form.class); // if (form != null) // { // RequestContext rc = RequestContext.get(); // if (rc.isPortletRequest()) // { // // restore url back to real wicket path as its going to be interpreted by the // // form itself // url = ((PortletRequestContext)rc).getLastEncodedPath(); // } // tag.put("onclick", form.getJsForInterfaceUrl(url)); // } // else // { // // TODO: following doesn't work with portlets, should be posted to a dynamic hidden // // form // // with an ActionURL or something // // NOTE: do not encode the url as that would give invalid // // JavaScript // tag.put("onclick", "window.location.href='" + url + // (url.toString().indexOf('?') > -1 ? "&" : "?") + getInputName() + // "=' + this.checked;"); // } } } super.onComponentTag(tag); }
From source file:com.wiquery.plugins.jqgrid.component.XMLDataRequestTarget.java
License:Apache License
/** * Encodes a string so it is safe to use inside CDATA blocks * /*from w ww . jav a 2 s .c om*/ * @param str * @return encoded string */ protected String encode(String str) { if (str == null) { return null; } return Strings.replaceAll(str, "]", "]^").toString(); }