List of usage examples for org.apache.wicket.util.string Strings isEmpty
public static boolean isEmpty(final CharSequence string)
string
is considered empty. From source file:org.artifactory.common.wicket.component.checkbox.styled.StyledCheckbox.java
License:Open Source License
@Override public boolean checkRequired() { if (isRequired()) { final String input = getInput(); return input == null && !isInputNullable() && !isEnabledInHierarchy() || !Strings.isEmpty(input); }/*from ww w. j av a 2 s. com*/ return true; }
From source file:org.artifactory.common.wicket.util.WicketUtils.java
License:Open Source License
/** * Get the absolute bookmarkable path of a page * * @param pageClass Page//from w ww. j a v a2s . com * @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)); }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebRequest.java
License:Apache License
/** * Returns base url without context or filter mapping. <p> Example: if current url is <p/> * <pre>//from w w w. j a v a2 s . co m * http://localhost:8080/context/filter/mapping/wicket/bookmarkable/com.foo.Page?1&id=2 * </pre> * <p/> the base url is <em>wicket/bookmarkable/com.foo.Page</em> </p> * * @see org.apache.wicket.request.Request#getClientUrl() */ @Override public Url getClientUrl() { if (errorAttributes != null && !Strings.isEmpty(errorAttributes.getRequestUri())) { String problematicURI = Url.parse(errorAttributes.getRequestUri(), getCharset()).toString(); return getContextRelativeUrl(problematicURI, filterPrefix); } else if (forwardAttributes != null && !Strings.isEmpty(forwardAttributes.getRequestUri())) { String forwardURI = Url.parse(forwardAttributes.getRequestUri(), getCharset()).toString(); // -- START BUG FIX // [YS] because it's a forward URL, the wicket filterPrefix might not be part or the URL // detect it by taking the second path element (e.g., /contextPath/forwardFilterPrefix/restOfPath) int contextPathLength = httpServletRequest.getContextPath().length(); int forwardFilterPrefixStart = contextPathLength + 1; // the trailing '/' String servletPath = forwardURI.substring(forwardFilterPrefixStart); // servlet path without leading '/' int forwardFilterPrefixEnd = servletPath.indexOf('/'); if (forwardFilterPrefixEnd == -1) { forwardFilterPrefixEnd = servletPath.length(); } String forwardFilterPrefix = forwardURI.substring(forwardFilterPrefixStart, forwardFilterPrefixStart + forwardFilterPrefixEnd); return getContextRelativeUrl(forwardURI, forwardFilterPrefix); // -- END BUG FIX } else if (!isAjax()) { return getContextRelativeUrl(httpServletRequest.getRequestURI(), filterPrefix); } else { String base = null; base = getHeader(HEADER_AJAX_BASE_URL); if (base == null) { base = getRequestParameters().getParameterValue(PARAM_AJAX_BASE_URL).toString(null); } Checks.notNull(base, "Current ajax request is missing the base url header or parameter"); return setParameters(Url.parse(base, getCharset())); } }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebRequest.java
License:Apache License
private Url getContextRelativeUrl(String uri, String filterPrefix) { if (filterPrefix.length() > 0 && !filterPrefix.endsWith("/")) { filterPrefix += "/"; }//from w w w .j a v a 2 s .c o m StringBuilder url = new StringBuilder(); uri = Strings.stripJSessionId(uri); final int start = httpServletRequest.getContextPath().length() + filterPrefix.length() + 1; url.append(uri.substring(start)); if (errorAttributes == null) { String query = httpServletRequest.getQueryString(); if (!Strings.isEmpty(query)) { url.append('?'); url.append(query); } } return setParameters(Url.parse(url.toString(), getCharset())); }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebRequest.java
License:Apache License
@Override public boolean shouldPreserveClientUrl() { return (errorAttributes != null && !Strings.isEmpty(errorAttributes.getRequestUri()) || forwardAttributes != null && !Strings.isEmpty(forwardAttributes.getRequestUri())); }
From source file:org.bindgen.wicket.AbstractBindingColumn.java
License:Apache License
/** {@inheritDoc} */ public boolean isSortable() { return !Strings.isEmpty(sortProperty); }
From source file:org.brixcms.demo.web.QueryStringHybridUrlCodingStrategy.java
License:Apache License
private void appendValue(AppendingStringBuffer url, String key, String value) { final String escapedKey = urlEncodePathComponent(key); final String escapedValue = urlEncodePathComponent(value); if (!Strings.isEmpty(escapedValue)) { url.append((url.indexOf("?") < 0) ? "?" : "&"); url.append(escapedKey).append("=").append(escapedValue); }/*w w w .j a va 2s .c o m*/ }
From source file:org.brixcms.demo.web.tile.ajax.AjaxDemoPanel.java
License:Apache License
public AjaxDemoPanel(String id) { super(id);// w w w . ja v a 2 s . c o m Form<Void> form = new Form<>("form"); add(form); final IModel<String> model = new IModel<String>() { private String value = null; @Override public String getObject() { return value; } @Override public void setObject(String object) { value = object; values.append("\n"); values.append(value); } @Override public void detach() { } }; final AutoCompleteTextField<String> field = new AutoCompleteTextField<String>("ac", model) { @Override protected Iterator<String> getChoices(String input) { if (Strings.isEmpty(input)) { List<String> emptyList = Collections.emptyList(); return emptyList.iterator(); } List<String> choices = new ArrayList<>(10); Locale[] locales = Locale.getAvailableLocales(); for (final Locale locale : locales) { final String country = locale.getDisplayCountry(); if (country.toUpperCase().startsWith(input.toUpperCase())) { choices.add(country); if (choices.size() == 10) { break; } } } return choices.iterator(); } }; form.add(field); final MultiLineLabel label = new MultiLineLabel("history", new PropertyModel<String>(this, "values")); label.setOutputMarkupId(true); form.add(label); field.add(new AjaxFormSubmitBehavior(form, "change") { @Override protected void onSubmit(AjaxRequestTarget target) { target.add(label); } @Override protected void onError(AjaxRequestTarget target) { } }); }
From source file:org.brixcms.jcr.wrapper.BrixFileNode.java
License:Apache License
public static boolean isText(String mimeType) { if (Strings.isEmpty(mimeType)) { return false; }//from w ww . j a v a2 s . c om if (mimeType.equals("text") || mimeType.startsWith("text/")) { return true; } if ("application/xml".equals(mimeType)) { return true; } return false; }
From source file:org.brixcms.jcr.wrapper.BrixFileNode.java
License:Apache License
/** * Returns the mime type for this node. If the property is not specified and <code>useExtension</code> is * <code>true</code>, tries to determine mime type from extension. * * @param useExtension//from ww w . j a v a 2 s. c o m * @return */ public String getMimeType(boolean useExtension) { // FIXME Shouldn't have direct dependency on SitePlugin String mime = getContent().getProperty("jcr:mimeType").getString(); if (useExtension && (Strings.isEmpty(mime) || mime.equals("application/octet-stream"))) { ResourceNodePlugin plugin = (ResourceNodePlugin) SitePlugin.get(getBrix()) .getNodePluginForType(ResourceNodePlugin.TYPE); return plugin.resolveMimeTypeFromFileName(getName()); } return mime; }