Package org.apache.wicket.response

Examples of org.apache.wicket.response.StringResponse


    // Make sure it is not cached by a client
    response.disableCaching();

    try
    {
      final StringResponse bodyResponse = new StringResponse();
      constructResponseBody(bodyResponse, encoding);
      CharSequence filteredResponse = invokeResponseFilters(bodyResponse);
      response.write(filteredResponse);
    }
    finally
View Full Code Here


        add(header);

        Response orgResponse = getRequestCycle().getResponse();
        try
        {
          final StringResponse response = new StringResponse();
          getRequestCycle().setResponse(response);

          // Render all header sections of all components on the page
          renderHead(header);

          // Make sure all Components interested in contributing to the header
          // and there attached behaviors are asked.
          final HtmlHeaderContainer finalHeader = header;
          visitChildren(new IVisitor()
          {
            /**
             * @see org.apache.wicket.Component.IVisitor#component(org.apache.wicket.Component)
             */
            public Object component(Component component)
            {
              component.renderHead(finalHeader);
              return CONTINUE_TRAVERSAL;
            }
          });
          response.close();

          if (response.getBuffer().length() > 0)
          {
            // @TODO it is not yet working properly. JDo to fix it
            log.error("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
            log.error("You probably forgot to add a <body> or <header> tag to your markup since no Header Container was \n" +
              "found but components where found which want to write to the <head> section.\n" +
              response.getBuffer());
            log.error("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
          }
        }
        catch (Exception e)
        {
View Full Code Here

   *
   * @return Response object. Must not be null
   */
  protected Response newResponse()
  {
    return new StringResponse();
  }
View Full Code Here

     * Prepare
     */
    @Before
    public void before()
    {
        final Response realResponse = new StringResponse();

        headerResponse = new HeaderResponse()
        {
            @Override
            protected Response getRealResponse()
View Full Code Here

    FilteringHeaderResponse headerResponse = new FilteringHeaderResponse(new HeaderResponse()
    {
      @Override
      protected Response getRealResponse()
      {
        return new StringResponse();
      }
    }, "headerBucketName", Collections.EMPTY_LIST);

    String filterName = "filterName";
    String headerContent = "content";
View Full Code Here

            // Temporarily replace the web response with a String response
            final Response webResponse = getResponse();

            try
            {
              final StringResponse response = new StringResponse();
              getRequestCycle().setResponse(response);

              Component component = getParent().get(id);
              if (component == null)
              {
                component = ComponentResolvers.resolve(getParent(), markupStream,
                  currentTag, null);

                // Must not be a Page and it must be connected to a parent.
                if (component.getParent() == null)
                {
                  component = null;
                }
              }

              if (component != null)
              {
                component.render();
                markupStream.skipComponent();
              }
              else
              {
                markupStream.next();
              }
              childTags.put(id, response.getBuffer());
            }
            finally
            {
              // Restore the original response
              getRequestCycle().setResponse(webResponse);
View Full Code Here

    // Make sure it is not cached by a client
    response.disableCaching();

    try
    {
      final StringResponse bodyResponse = new StringResponse();
      responseObject.writeTo(bodyResponse, encoding);
      CharSequence filteredResponse = invokeResponseFilters(bodyResponse);
      response.write(filteredResponse);
    }
    finally
View Full Code Here

    if (filterName == null || !responseFilterMap.containsKey(filterName))
    {
      return "";
    }
    List<HeaderItem> resp = responseFilterMap.get(filterName);
    final StringResponse strResponse = new StringResponse();
    IHeaderResponse headerRenderer = new HeaderResponse()
    {
      @Override
      protected Response getRealResponse()
      {
        return strResponse;
      }

      @Override
      public boolean wasRendered(Object object)
      {
        return FilteringHeaderResponse.this.getRealResponse().wasRendered(object);
      }

      @Override
      public void markRendered(Object object)
      {
        FilteringHeaderResponse.this.getRealResponse().markRendered(object);
      }
    };

    ResourceAggregator resourceAggregator = new ResourceAggregator(headerRenderer);

    for (HeaderItem curItem : resp)
    {
      resourceAggregator.render(curItem);
    }

    resourceAggregator.close();

    return strResponse.getBuffer();
  }
View Full Code Here

      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));
          }
        }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void writeJavaScriptUrl() throws Exception
  {
    StringResponse response = new StringResponse();
    String url = "some/url;jsessionid=1234?p1=v1&p2=v2";
    String id = "some&bad%id";
    boolean defer = true;
    String charset = "some&bad%%charset";
    JavaScriptUtils.writeJavaScriptUrl(response, url, id, defer, charset);

    assertEquals(
      "<script type=\"text/javascript\" id=\"some&amp;bad%id\" defer=\"defer\" charset=\"some&amp;bad%%charset\" src=\"some/url;jsessionid=1234?p1=v1&p2=v2\"></script>\n",
      response.toString());
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.response.StringResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.