Search in sources :

Example 1 with Response

use of org.apache.wicket.request.Response in project midpoint by Evolveum.

the class Form method onComponentTagBody.

@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
    super.onComponentTagBody(markupStream, openTag);
    if (addFakeInputFields) {
        final Response response = getResponse();
        response.write("<input style=\"display:none\">\n" + "<input type=\"password\" style=\"display:none\">");
    }
}
Also used : Response(org.apache.wicket.request.Response)

Example 2 with Response

use of org.apache.wicket.request.Response in project wicket by apache.

the class HtmlHeaderContainer method onComponentTagBody.

/**
 * First render the body of the component. And if it is the header component of a Page (compared
 * to a Panel or Border), then get the header sections from all component in the hierarchy and
 * render them as well.
 */
@Override
public final void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
    // We are able to automatically add <head> to the page if it is
    // missing. But we only want to add it, if we have content to be
    // written to its body. Thus we first write the output into a
    // StringResponse and if not empty, we copy it to the original
    // web response.
    // Temporarily replace the web response with a String response
    final Response webResponse = getResponse();
    try {
        // Create a (string) response for all headers contributed by any component on the Page.
        final StringResponse response = new StringResponse();
        getRequestCycle().setResponse(response);
        IHeaderResponse headerResponse = getHeaderResponse();
        if (!response.equals(headerResponse.getResponse())) {
            getRequestCycle().setResponse(headerResponse.getResponse());
        }
        // Render the header sections of all components on the page
        AbstractHeaderRenderStrategy.get().renderHeader(this, new HeaderStreamState(markupStream, openTag), getPage());
        // Close the header response before rendering the header container itself
        // See https://issues.apache.org/jira/browse/WICKET-3728
        headerResponse.close();
        // Cleanup extraneous CR and LF from the response
        CharSequence output = getCleanResponse(response);
        // Automatically add <head> if necessary
        if (output.length() > 0) {
            if (renderOpenAndCloseTags()) {
                webResponse.write("<head>");
            }
            webResponse.write(output);
            if (renderOpenAndCloseTags()) {
                webResponse.write("</head>");
            }
        }
    } finally {
        // Restore the original response
        getRequestCycle().setResponse(webResponse);
    }
}
Also used : HeaderResponse(org.apache.wicket.markup.head.internal.HeaderResponse) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) StringResponse(org.apache.wicket.response.StringResponse) Response(org.apache.wicket.request.Response) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) StringResponse(org.apache.wicket.response.StringResponse)

Example 3 with Response

use of org.apache.wicket.request.Response in project wicket by apache.

the class HtmlHeaderContainer method renderHeaderTagBody.

/**
 * Renders the content of the &lt;head&gt; section of the page, including &lt;wicket:head&gt;
 * sections in subclasses of the page. For every child-component, the content is rendered to a
 * string and passed to {@link IHeaderResponse}.
 *
 * @param headerStreamState
 */
public void renderHeaderTagBody(HeaderStreamState headerStreamState) {
    if (headerStreamState == null)
        return;
    final Response oldResponse = getRequestCycle().getResponse();
    try {
        // Create a separate (string) response for the header container itself
        final StringResponse bodyResponse = new StringResponse();
        getRequestCycle().setResponse(bodyResponse);
        // render the header section directly associated with the markup
        super.onComponentTagBody(headerStreamState.getMarkupStream(), headerStreamState.getOpenTag());
        CharSequence bodyOutput = getCleanResponse(bodyResponse);
        if (bodyOutput.length() > 0) {
            getHeaderResponse().render(new PageHeaderItem(bodyOutput));
        }
    } finally {
        getRequestCycle().setResponse(oldResponse);
    }
}
Also used : HeaderResponse(org.apache.wicket.markup.head.internal.HeaderResponse) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) StringResponse(org.apache.wicket.response.StringResponse) Response(org.apache.wicket.request.Response) StringResponse(org.apache.wicket.response.StringResponse) PageHeaderItem(org.apache.wicket.markup.head.PageHeaderItem)

Example 4 with Response

use of org.apache.wicket.request.Response in project wicket by apache.

the class ResponseBufferZone method execute.

public CharSequence execute() {
    final int originalStreamPos = stream.getCurrentIndex();
    final Response original = cycle.getResponse();
    final StringResponse buffer = new StringResponse();
    cycle.setResponse(buffer);
    try {
        executeInsideBufferedZone();
        return buffer.getBuffer();
    } finally {
        cycle.setResponse(original);
        stream.setCurrentIndex(originalStreamPos);
    }
}
Also used : StringResponse(org.apache.wicket.response.StringResponse) Response(org.apache.wicket.request.Response) StringResponse(org.apache.wicket.response.StringResponse)

Example 5 with Response

use of org.apache.wicket.request.Response in project wicket by apache.

the class BorderBehavior method afterRender.

@Override
public void afterRender(final Component component) {
    final MarkupStream stream = getMarkupStream(component);
    final Response response = component.getResponse();
    while (stream.isCurrentIndexInsideTheStream()) {
        MarkupElement elem = stream.get();
        stream.next();
        if (elem instanceof WicketTag) {
            WicketTag wTag = (WicketTag) elem;
            if (wTag.isBorderTag() && wTag.isClose()) {
                break;
            } else {
                throw new WicketRuntimeException("Unexpected tag encountered in markup of component border " + getClass().getName() + ". Tag: " + wTag.toString() + ", expected tag: </wicket:border>");
            }
        }
        response.write(elem.toCharSequence());
    }
}
Also used : Response(org.apache.wicket.request.Response) WicketTag(org.apache.wicket.markup.WicketTag) WicketRuntimeException(org.apache.wicket.WicketRuntimeException) MarkupStream(org.apache.wicket.markup.MarkupStream) MarkupElement(org.apache.wicket.markup.MarkupElement)

Aggregations

Response (org.apache.wicket.request.Response)31 IHeaderResponse (org.apache.wicket.markup.head.IHeaderResponse)9 WebResponse (org.apache.wicket.request.http.WebResponse)9 StringResponse (org.apache.wicket.response.StringResponse)9 Request (org.apache.wicket.request.Request)8 RequestCycle (org.apache.wicket.request.cycle.RequestCycle)8 HeaderResponse (org.apache.wicket.markup.head.internal.HeaderResponse)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)4 MockApplication (org.apache.wicket.mock.MockApplication)4 Before (org.junit.Before)4 Session (org.apache.wicket.Session)3 IRequestCycle (org.apache.wicket.request.IRequestCycle)3 WicketTester (org.apache.wicket.util.tester.WicketTester)3 Test (org.junit.Test)3 Component (org.apache.wicket.Component)2 WebSession (org.apache.wicket.protocol.http.WebSession)2 Member (com.hazelcast.core.Member)1 MemberAttributeEvent (com.hazelcast.core.MemberAttributeEvent)1 MembershipEvent (com.hazelcast.core.MembershipEvent)1