Example #1
0
 /**
  * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT.
  *
  * <p>Temporarily replaces the response with a StringResponse to capture the header output for
  * this part of the stream and pass it to {@link IHeaderResponse}.
  *
  * @see org.apache.wicket.MarkupContainer#renderNext(org.apache.wicket.markup.MarkupStream)
  */
 @Override
 protected final boolean renderNext(MarkupStream markupStream) {
   StringResponse markupHeaderResponse = new StringResponse();
   Response oldResponse = getResponse();
   RequestCycle.get().setResponse(markupHeaderResponse);
   try {
     boolean ret = super.renderNext(markupStream);
     getHeaderResponse().render(new PageHeaderItem(markupHeaderResponse.getBuffer()));
     return ret;
   } finally {
     RequestCycle.get().setResponse(oldResponse);
   }
 }
Example #2
0
  /**
   * Runs the configured {@link IResponseFilter}s over the constructed Ajax response
   *
   * @param contentResponse the Ajax {@link Response} body
   * @return filtered response
   */
  private AppendingStringBuffer invokeResponseFilters(final StringResponse contentResponse) {
    AppendingStringBuffer responseBuffer = new AppendingStringBuffer(contentResponse.getBuffer());

    List<IResponseFilter> responseFilters =
        Application.get().getRequestCycleSettings().getResponseFilters();

    if (responseFilters != null) {
      for (IResponseFilter filter : responseFilters) {
        responseBuffer = filter.filter(responseBuffer);
      }
    }
    return responseBuffer;
  }
Example #3
0
 /**
  * @param response
  * @return Cleaned up response
  */
 private CharSequence getCleanResponse(final StringResponse response) {
   CharSequence output = response.getBuffer();
   if (output.length() > 0) {
     if (output.charAt(0) == '\r') {
       for (int i = 2; i < output.length(); i += 2) {
         char ch = output.charAt(i);
         if (ch != '\r') {
           output = output.subSequence(i - 2, output.length());
           break;
         }
       }
     } else if (output.charAt(0) == '\n') {
       for (int i = 1; i < output.length(); i++) {
         char ch = output.charAt(i);
         if (ch != '\n') {
           output = output.subSequence(i - 1, output.length());
           break;
         }
       }
     }
   }
   return output;
 }