Package org.apache.wicket.request.cycle

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


   */
  public void renderXmlDecl(final WebPage page, boolean insert)
  {
    if (insert || MarkupType.XML_MIME.equalsIgnoreCase(page.getMarkupType().getMimeType()))
    {
      final RequestCycle cycle = RequestCycle.get();

      if (insert == false)
      {
        WebRequest request = (WebRequest)cycle.getRequest();

        String accept = request.getHeader("Accept");
        insert = ((accept == null) || (accept.indexOf(MarkupType.XML_MIME) != -1));
      }

      if (insert)
      {
        WebResponse response = (WebResponse)cycle.getResponse();
        response.write("<?xml version='1.0'");
        String encoding = getRequestCycleSettings().getResponseRequestEncoding();
        if (Strings.isEmpty(encoding) == false)
        {
          response.write(" encoding='");
View Full Code Here


   * page. Prior to this, the other constructor should already have been called.
   */
  public BrowserInfoPage()
  {
    initComps();
    RequestCycle requestCycle = getRequestCycle();
    WebSession session = (WebSession)getSession();
    WebClientInfo clientInfo = session.getClientInfo();
    if (clientInfo == null)
    {
      clientInfo = new WebClientInfo(requestCycle);
View Full Code Here

  public final RequestCycle createRequestCycle(final Request request, final Response response)
  {
    RequestCycleContext context = new RequestCycleContext(request, response,
      getRootRequestMapper(), getExceptionMapperProvider().get());

    RequestCycle requestCycle = getRequestCycleProvider().get(context);
    requestCycle.getListeners().add(requestCycleListeners);
    requestCycle.getListeners().add(new AbstractRequestCycleListener()
    {
      @Override
      public void onDetach(final RequestCycle requestCycle)
      {
        if (Session.exists())
        {
          Session.get().getPageManager().commitRequest();
        }

        if (Application.exists())
        {
          IRequestLogger requestLogger = Application.get().getRequestLogger();
          if (requestLogger != null)
          {
            requestLogger.requestTime((System.currentTimeMillis() - requestCycle.getStartTime()));
          }
        }
      }
    });
    return requestCycle;
View Full Code Here

  private static class DefaultRequestCycleProvider implements IRequestCycleProvider
  {
    @Override
    public RequestCycle get(final RequestCycleContext context)
    {
      return new RequestCycle(context);
    }
View Full Code Here

  @Override
  public String getVersion(IStaticCacheableResource resource)
  {
    // get current request cycle
    final RequestCycle requestCycle = ThreadContext.getRequestCycle();

    // cache instance
    Map<Serializable, String> cache = null;

    // cache key
    Serializable key = null;

    // is request cycle available?
    if (requestCycle != null)
    {
      // retrieve cache from current request cycle
      cache = requestCycle.getMetaData(CACHE_KEY);

      // create caching key
      key = resource.getCacheKey();

      // does cache exist within current request cycle?
      if (cache == null)
      {
        // no, so create it
        requestCycle.setMetaData(CACHE_KEY, cache = Generics.newHashMap());
      }
      else if (cache.containsKey(key))
      {
        // lookup timestamp from cache (may contain NULL values which are valid)
        return cache.get(key);
View Full Code Here

    }
  }

  private RenderPageRequestHandler createPageRequestHandler(PageProvider pageProvider)
  {
    RequestCycle requestCycle = RequestCycle.get();

    if (requestCycle == null)
    {
      throw new IllegalStateException(
        "there is no current request cycle attached to this thread");
View Full Code Here

    return new RenderPageRequestHandler(pageProvider, redirect);
  }

  private boolean isProcessingAjaxRequest()
  {
    RequestCycle rc = RequestCycle.get();
    Request request = rc.getRequest();
    if (request instanceof WebRequest)
    {
      return ((WebRequest)request).isAjax();
    }
    return false;
View Full Code Here

   * @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

   */
  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

   *            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

TOP

Related Classes of org.apache.wicket.request.cycle.RequestCycle

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.