Examples of RequestCycle


Examples of org.apache.wicket.request.cycle.RequestCycle

   * @return the page being rendered when the exception was thrown, or {@code null} if it cannot
   *         be extracted
   */
  private Page extractCurrentPage()
  {
    final RequestCycle requestCycle = RequestCycle.get();

    IRequestHandler handler = requestCycle.getActiveRequestHandler();

    if (handler == null)
    {
      handler = requestCycle.getRequestHandlerScheduledAfterCurrent();
    }

    if (handler instanceof IPageRequestHandler)
    {
      IPageRequestHandler pageRequestHandler = (IPageRequestHandler)handler;
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

   */
  public static CharSequence renderPage(final PageProvider pageProvider)
  {
    Application application = Application.get();

    RequestCycle originalRequestCycle = RequestCycle.get();

    BufferedWebResponse tempResponse = new BufferedWebResponse(null);

    RequestCycle tempRequestCycle = application.createRequestCycle(originalRequestCycle.getRequest(), tempResponse);

    try
    {
      ThreadContext.setRequestCycle(tempRequestCycle);
      pageProvider.getPageInstance().renderPage();
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

   *            the component to render.
   * @return the html rendered by the component
   */
  public static CharSequence renderComponent(final Component component)
  {
    RequestCycle requestCycle = RequestCycle.get();

    final Response originalResponse = requestCycle.getResponse();
    BufferedWebResponse tempResponse = new BufferedWebResponse(null);

    MarkupContainer oldParent = component.getParent();

    try
    {
      requestCycle.setResponse(tempResponse);

      // add the component to a dummy page just for the rendering
      RenderPage page = new RenderPage(component);
      page.internalInitialize();

      component.render();
    }
    finally
    {
      if (oldParent != null)
      {
        oldParent.add(component); // re-add the child to its old parent
      }

      requestCycle.setResponse(originalResponse);
    }

    return tempResponse.getText();
  }
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

   * @see org.apache.wicket.core.request.handler.IPageRequestHandler#respond(org.apache.wicket.request.IRequestCycle)
   */
  @Override
  public final void respond(final IRequestCycle requestCycle)
  {
    final RequestCycle rc = (RequestCycle)requestCycle;
    final WebResponse response = (WebResponse)requestCycle.getResponse();

    if (shouldRedirectToPage(requestCycle))
    {
      // the page itself has been added to the request target, we simply issue a redirect
      // back to the page
      IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
      final String url = rc.urlFor(handler).toString();
      response.sendRedirect(url);
      return;
    }

    respondersFrozen = true;
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

    }

    @Override
    protected void respond(final AjaxRequestTarget target)
    {
      RequestCycle requestCycle = RequestCycle.get();
      boolean save = requestCycle.getRequest()
        .getRequestParameters()
        .getParameterValue("save")
        .toBoolean(false);

      if (save)
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

    baseUrl.setPort(80);
    when(webRequest.getClientUrl()).thenReturn(baseUrl);

    UrlRenderer renderer = new UrlRenderer(webRequest);

    RequestCycle requestCycle = mock(RequestCycle.class);
    ThreadContext.setRequestCycle(requestCycle);
    when(requestCycle.getUrlRenderer()).thenReturn(renderer);

    HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
    when(httpServletResponse.encodeURL(Matchers.eq(url))).thenReturn(url + ";foo");

    ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

    baseUrl.setPort(80);
    when(webRequest.getClientUrl()).thenReturn(baseUrl);

    UrlRenderer renderer = new UrlRenderer(webRequest);

    RequestCycle requestCycle = mock(RequestCycle.class);
    ThreadContext.setRequestCycle(requestCycle);
    when(requestCycle.getUrlRenderer()).thenReturn(renderer);

    HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
    when(httpServletResponse.encodeRedirectURL(Matchers.eq(url))).thenReturn(url + ";foo");

    ServletWebResponse webResponse = new ServletWebResponse(webRequest, httpServletResponse);
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

  protected abstract void onRequest(String input, RequestCycle requestCycle);

  @Override
  protected void respond(final AjaxRequestTarget target)
  {
    final RequestCycle requestCycle = RequestCycle.get();
    final String val = requestCycle.getRequest()
      .getRequestParameters()
      .getParameterValue(settings.getParameterName())
      .toOptionalString();

    onRequest(val, requestCycle);
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

      header = new AjaxHtmlHeaderContainer(this);
      final Page parentPage = component.getPage();
      parentPage.addOrReplace(header);
    }

    RequestCycle requestCycle = component.getRequestCycle();

    // save old response, set new
    Response oldResponse = requestCycle.setResponse(encodingHeaderResponse);

    try {
      encodingHeaderResponse.reset();

      IHeaderRenderStrategy strategy = AbstractHeaderRenderStrategy.get();

      strategy.renderHeader(header, null, component);
    } finally {
      // revert to old response
      requestCycle.setResponse(oldResponse);
    }

    writeHeaderContribution(response);

    headerRendering = false;
View Full Code Here

Examples of org.apache.wicket.request.cycle.RequestCycle

   * @see org.apache.wicket.page.IPageManagerContext#getRequestData()
   */
  @Override
  public Object getRequestData()
  {
    RequestCycle requestCycle = RequestCycle.get();
    if (requestCycle == null)
    {
      throw new IllegalStateException("Not a request thread.");
    }
    return requestCycle.getMetaData(requestCycleMetaDataKey);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.