Search in sources :

Example 1 with IClusterable

use of org.apache.wicket.util.io.IClusterable in project wicket by apache.

the class Component method internalRenderHead.

/**
 * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!
 *
 * Print to the web response what ever the component wants to contribute to the head section.
 * Make sure that all attached behaviors are asked as well.
 * <p>
 * NOT intended for overriding by framework clients. Rather, use
 * {@link Component#renderHead(org.apache.wicket.markup.head.IHeaderResponse)}
 * </p>
 *
 * @param container
 *            The HtmlHeaderContainer
 */
public void internalRenderHead(final HtmlHeaderContainer container) {
    if (isVisibleInHierarchy() && isRenderAllowed()) {
        if (log.isDebugEnabled()) {
            log.debug("internalRenderHead: {}", toString(false));
        }
        IHeaderResponse response = container.getHeaderResponse();
        // Allow component to contribute
        if (response.wasRendered(this) == false) {
            StringResponse markupHeaderResponse = new StringResponse();
            Response oldResponse = getResponse();
            RequestCycle.get().setResponse(markupHeaderResponse);
            try {
                // Make sure the markup source strategy contributes to the header first
                // to be backward compatible. WICKET-3761
                getMarkupSourcingStrategy().renderHead(this, container);
                CharSequence headerContribution = markupHeaderResponse.getBuffer();
                if (Strings.isEmpty(headerContribution) == false) {
                    response.render(StringHeaderItem.forString(headerContribution));
                }
            } finally {
                RequestCycle.get().setResponse(oldResponse);
            }
            // Then let the component itself to contribute to the header
            renderHead(response);
            response.markRendered(this);
        }
        // Then ask all behaviors
        for (Behavior behavior : getBehaviors()) {
            if (isBehaviorAccepted(behavior)) {
                if (response.wasRendered(behavior) == false) {
                    behavior.renderHead(this, response);
                    List<IClusterable> pair = Arrays.asList(this, behavior);
                    response.markRendered(pair);
                }
            }
        }
    }
}
Also used : StringResponse(org.apache.wicket.response.StringResponse) Response(org.apache.wicket.request.Response) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) IClusterable(org.apache.wicket.util.io.IClusterable) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) StringResponse(org.apache.wicket.response.StringResponse) Behavior(org.apache.wicket.behavior.Behavior)

Aggregations

Behavior (org.apache.wicket.behavior.Behavior)1 IHeaderResponse (org.apache.wicket.markup.head.IHeaderResponse)1 Response (org.apache.wicket.request.Response)1 StringResponse (org.apache.wicket.response.StringResponse)1 IClusterable (org.apache.wicket.util.io.IClusterable)1