Example usage for org.apache.wicket.request.component IRequestableComponent getPageRelativePath

List of usage examples for org.apache.wicket.request.component IRequestableComponent getPageRelativePath

Introduction

In this page you can find the example usage for org.apache.wicket.request.component IRequestableComponent getPageRelativePath.

Prototype

String getPageRelativePath();

Source Link

Document

Gets this component's path.

Usage

From source file:com.wyndhamjade.util.wicket.newrelic.NewRelicRequestCycleListener.java

License:Apache License

private String componentToPath(final IRequestableComponent c) {
    return c.getPageRelativePath().replace(':', '/');
}

From source file:fiftyfive.wicket.util.LoggingUtils.java

License:Apache License

/**
 * Returns a description of component or page that is currently being
 * processed by the Wicket framework. If a component is being executed, the
 * description will be in the form://from  w  w w. j a  va 2 s.  c  om
 * <pre class="example">
 * PageClass &gt; ComponentClass (superclass if component is anonymous) [wicket:id path]</pre>
 * <p>
 * Example:
 * <pre class="example">
 * MyPage &gt; MyPanel$1 (Link) [path:to:link]</pre>
 * <p>
 * If a page is being rendered, the description will be the page class.
 */
public static String describeRequestComponent() {
    IRequestHandler handler = guessOriginalRequestHandler();
    Class<? extends IRequestablePage> pageClass = null;
    IRequestableComponent component = null;

    if (handler instanceof IPageClassRequestHandler) {
        pageClass = ((IPageClassRequestHandler) handler).getPageClass();
    }
    if (handler instanceof IComponentRequestHandler) {
        component = ((IComponentRequestHandler) handler).getComponent();
    }

    StringBuffer desc = new StringBuffer();

    if (pageClass != null) {
        desc.append(Classes.simpleName(pageClass));
    }
    if (component != null) {
        String classDesc = null;
        if (component.getClass().isAnonymousClass()) {
            classDesc = String.format("%s (%s)", Classes.simpleName(component.getClass()),
                    Classes.simpleName(component.getClass().getSuperclass()));
        } else {
            classDesc = Classes.simpleName(component.getClass());
        }

        desc.append(String.format(" > %s [%s]", classDesc, component.getPageRelativePath()));
    }

    return desc.length() > 0 ? desc.toString() : null;
}