Example usage for org.apache.wicket.util.string PrependingStringBuffer PrependingStringBuffer

List of usage examples for org.apache.wicket.util.string PrependingStringBuffer PrependingStringBuffer

Introduction

In this page you can find the example usage for org.apache.wicket.util.string PrependingStringBuffer PrependingStringBuffer.

Prototype

public PrependingStringBuffer(final String start) 

Source Link

Document

Constructs and direct inserts the given string.

Usage

From source file:com.servoy.j2db.server.headlessclient.dataui.ServoySubmitPagingNavigationIncrementLink.java

License:Open Source License

/**
 * @see org.apache.wicket.markup.html.form.IFormSubmittingComponent#getInputName()
 *///from   w  w  w  .ja va2s  .c o  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 ww.j ava  2 s . c o 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.wicketstuff.security.components.SecureComponentHelper.java

License:Apache License

/**
 * Builds an alias string for {@link MarkupContainer}s.
 * //from w  w w.  j av a 2 s .  c  om
 * @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.
 * //from  w w w  .ja  va2 s.  c  om
 * @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;
}