Example usage for org.apache.wicket Component isVisibleInHierarchy

List of usage examples for org.apache.wicket Component isVisibleInHierarchy

Introduction

In this page you can find the example usage for org.apache.wicket Component isVisibleInHierarchy.

Prototype

public final boolean isVisibleInHierarchy() 

Source Link

Document

Checks if the component itself and all its parents are visible.

Usage

From source file:org.wicketstuff.minis.behavior.reflection.ReflectionBehavior.java

License:Apache License

/**
 * Adds the reflection.js javascript to the page.
 * //w ww .  j  a  va  2  s .co m
 * @see Behavior#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
 */
@Override
public void renderHead(Component c, final IHeaderResponse response) {
    super.renderHead(c, response);
    response.render(JavaScriptHeaderItem.forReference(REFLECTION_JS));

    final StringBuilder sb = new StringBuilder();
    for (final Component component : components)
        if (component.isVisibleInHierarchy()) {
            sb.append(Javascript.show(component.getMarkupId(), reflectionOpacity, reflectionHeight));
            sb.append("\n");
        }
    response.render(OnLoadHeaderItem.forScript(sb.toString()));
}

From source file:org.wicketstuff.minis.reflection.ReflectionBehavior.java

License:Apache License

/**
 * Adds the reflection.js javascript to the page.
 * /*from w w  w .  j  a v  a  2s .co  m*/
 * @see org.apache.wicket.behavior.AbstractBehavior#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
 */
@Override
public void renderHead(Component c, final IHeaderResponse response) {
    super.renderHead(c, response);
    response.renderJavaScriptReference(REFLECTION_JS);

    final StringBuilder sb = new StringBuilder();
    for (final Component component : components)
        if (component.isVisibleInHierarchy()) {
            sb.append(Javascript.show(component.getMarkupId(), reflectionOpacity, reflectionHeight));
            sb.append("\n");
        }
    response.renderOnLoadJavaScript(sb.toString());
}

From source file:sf.wicklet.gwt.server.ajax.impl.AbstractGwtAjaxResponse.java

License:Apache License

/**
 * @param response/*from   w  w w .  ja  v  a2  s  . c om*/
 *      the response to write to
 * @param component
 *      to component which will contribute to the header
 */
protected void writeHeaderContribution(final Response response, final Component component) {
    headerRendering = true;
    // create the htmlheadercontainer if needed
    if (header == null) {
        header = new AjaxHtmlHeaderContainer(this);
        final Page parentPage = component.getPage();
        parentPage.addOrReplace(header);
    }
    final RequestCycle requestCycle = component.getRequestCycle();
    // save old response, set new
    final Response oldResponse = requestCycle.setResponse(encodingHeaderResponse);
    try {
        encodingHeaderResponse.reset();
        // render the head of component and all it's children
        component.renderHead(header);
        if (component instanceof MarkupContainer) {
            ((MarkupContainer) component).visitChildren(new IVisitor<Component, Void>() {
                @Override
                public void component(final Component component, final IVisit<Void> visit) {
                    if (component.isVisibleInHierarchy()) {
                        component.renderHead(header);
                    } else {
                        visit.dontGoDeeper();
                    }
                }
            });
        }
    } finally {
        // revert to old response
        requestCycle.setResponse(oldResponse);
    }
    writeHeaderContribution(response);
    headerRendering = false;
}