Package org.apache.wicket.response

Examples of org.apache.wicket.response.StringResponse


        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;
    }
    for (IHeaderResponseFilter filter : filters)
    {
      responseFilterMap.put(filter.getName(), new StringResponse());
    }
  }
View Full Code Here

  {
    if (filterName == null)
    {
      return "";
    }
    StringResponse resp = responseFilterMap.get(filterName);
    return resp == null ? "" : resp.getBuffer();
  }
View Full Code Here

        attributes = new Attributes(cycle.getRequest(), cycle.getResponse());
      }
      else
      {
        // use empty request and response in case of non-http thread. WICKET-5532
        attributes = new Attributes(new MockWebRequest(Url.parse("")), new StringResponse());
      }
      byte[] processedBytes = processResponse(attributes, bytes);
      return new ByteArrayInputStream(processedBytes);
    }
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

      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

            // 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.render(markupStream);
              }
              childTags.put(id, response.getBuffer());
            }
            finally
            {
              // Restore the original response
              getRequestCycle().setResponse(webResponse);
View Full Code Here

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

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

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

      // In any case, first render the header section directly associated
      // with the markup
      super.onComponentTagBody(markupStream, openTag);

      // Render all header sections of all components on the page
      renderHeaderSections(getPage(), this);

      // Automatically add <head> if necessary
      CharSequence output = response.getBuffer();
      if (output.length() > 0)
      {
        if (output.charAt(0) == '\r')
        {
          for (int i = 2; i < output.length(); i += 2)
View Full Code Here

           */
          @Override
          public void respond(RequestCycle requestCycle)
          {
            if (requestParams.getString("email") != null) {
              final StringResponse emailResponse = new StringResponse();
              final WebResponse originalResponse = (WebResponse)RequestCycle.get().getResponse();
              RequestCycle.get().setResponse(emailResponse);
              super.respond(requestCycle);
              // Here send the email instead of dumping it to stdout!
              System.out.println(emailResponse.toString());
              RequestCycle.get().setResponse(originalResponse);
              RequestCycle.get().setRequestTarget(new BookmarkablePageRequestTarget(Sent.class));
            } else {
              super.respond(requestCycle);
            }
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.