List of usage examples for org.apache.wicket.util.string PrependingStringBuffer toString
@Override
public String toString()
From source file:com.servoy.j2db.server.headlessclient.dataui.ServoySubmitPagingNavigationIncrementLink.java
License:Open Source License
/** * @see org.apache.wicket.markup.html.form.IFormSubmittingComponent#getInputName() */// w ww . j av a 2s . co m public String getInputName() { // TODO: This is a copy & paste from the FormComponent class. String id = getId(); final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length()); Component c = this; while (true) { inputName.prepend(id); c = c.getParent(); if (c == null || (c instanceof Form && ((Form) c).isRootForm()) || c instanceof Page) { break; } inputName.prepend(Component.PATH_SEPARATOR); id = c.getId(); } return inputName.toString(); }
From source file:org.artifactory.common.wicket.component.links.TitledSubmitLink.java
License:Open Source License
@Override public String getInputName() { // TODO: This is a copy & paste from the FormComponent class. String id = getId();/* w w w . j a v a2 s. co m*/ final PrependingStringBuffer inputName = new PrependingStringBuffer(id.length()); Component c = this; while (true) { inputName.prepend(id); c = c.getParent(); if (c == null || (c instanceof Form && ((Form) c).isRootForm()) || c instanceof Page) { break; } inputName.prepend(Component.PATH_SEPARATOR); id = c.getId(); } // having input name "submit" causes problems with javascript, so we // create a unique string to replace it by prepending a path separator if ("submit".equals(inputName.toString())) { inputName.prepend(Component.PATH_SEPARATOR); } return inputName.toString(); }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebRequest.java
License:Apache License
@Override public String getPrefixToContextPath() { PrependingStringBuffer buffer = new PrependingStringBuffer(); Url filterPrefixUrl = Url.parse(filterPrefix, getCharset()); for (int i = 0; i < filterPrefixUrl.getSegments().size() - 1; ++i) { buffer.prepend("../"); }/*from w w w. j a v a2s .c om*/ return buffer.toString(); }
From source file:org.brixcms.web.util.PathLabel.java
License:Apache License
@Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { PrependingStringBuffer b = new PrependingStringBuffer(); BrixNode current = getModelObject(); while (true) { StringBuilder builder = new StringBuilder(); writePath(current, builder, current.equals(getModelObject())); if (b.length() > 0) { b.prepend(" / "); }/*w w w . ja v a 2s .com*/ b.prepend(builder.toString()); if (current.getDepth() == 0 || current.getPath().equals(rootPath)) { break; } current = (BrixNode) current.getParent(); } final Response r = getResponse(); r.write(b.toString()); }
From source file:org.hippoecm.frontend.model.JcrItemModel.java
License:Apache License
private void doSave() { if (!isValidSession()) { return;//from w w w .j ava 2 s . co m } try { relPath = null; Node node = null; PrependingStringBuffer spb = new PrependingStringBuffer(); // if we have an item, use it to update the path Item item = getObject(); if (item != null) { try { absPath = item.getPath(); if (item.isNode()) { node = (Node) item; } else { node = item.getParent(); spb.prepend(item.getName()); spb.prepend('/'); } } catch (InvalidItemStateException ex) { // ignore; item doesn't exist anymore super.detach(); } } // no node was found, use path to resolve an ancestor if (node == null) { if (absPath != null) { Session session = UserSession.get().getJcrSession(); String path = absPath; while (path.lastIndexOf('/') > 0) { spb.prepend(path.substring(path.lastIndexOf('/'))); path = path.substring(0, path.lastIndexOf('/')); try { node = (Node) session.getItem(path); break; } catch (PathNotFoundException ignored) { } } } else { log.debug("Neither path nor uuid present"); return; } } while (node != null && JcrHelper.isVirtualNode(node)) { if (node.getIndex() > 1) { spb.prepend(']'); spb.prepend(Integer.toString(node.getIndex())); spb.prepend('['); } spb.prepend(node.getName()); spb.prepend('/'); node = node.getParent(); } if (node != null) { uuid = node.getIdentifier(); if (spb.length() > 1) { relPath = spb.toString().substring(1); } } } catch (RepositoryException ex) { log.error(ex.toString()); } }
From source file:org.wicketstuff.security.components.SecureComponentHelper.java
License:Apache License
/** * Builds an alias string for {@link MarkupContainer}s. * /*from ww w . ja v a 2 s. c o m*/ * @param container * @return an alias */ public static String containerAlias(MarkupContainer container) { if (container == null) throw new SecurityException("specified markupcontainer is null"); MarkupContainer parent = container; PrependingStringBuffer buffer = new PrependingStringBuffer(150); while (parent != null) { if (buffer.length() > 0) buffer.prepend(PATH_SEPARATOR); buffer.prepend(parent.getClass().getName()); parent = parent.getParent(); } return buffer.toString(); }
From source file:org.wicketstuff.security.components.SecureComponentHelper.java
License:Apache License
/** * Builds a set of aliases for this component. Each alias can be used as name in Permission. * // w w w.j a v a2 s . c o m * @param component * @return an array with aliases for this component */ public static String[] containerAliasses(Component component) { if (component == null) throw new SecurityException("specified component is null"); MarkupContainer parent = null; if (component instanceof MarkupContainer) parent = (MarkupContainer) component; else parent = component.getParent(); if (parent == null) return new String[0]; String alias = containerAlias(parent); String[] split = alias.split(PATH_SEPARATOR); String[] result = new String[split.length + (split.length - 1)]; PrependingStringBuffer buffer = new PrependingStringBuffer(200); int index = result.length - 1; for (int i = split.length - 1; i >= 0; i--) { if (i < split.length - 1) { result[index] = split[i]; index--; buffer.prepend(PATH_SEPARATOR); } buffer.prepend(split[i]); result[index] = buffer.toString(); index--; } return result; }