Package org.apache.wicket

Examples of org.apache.wicket.RequestCycle


  @Override
  public void onComponentTag(final Component component, final ComponentTag tag)
  {
    tag.put("xmlns:wicket", "http://wicket.apache.org");

    final RequestCycle requestCycle = RequestCycle.get();

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

    // Create a new response object
    final Response response = newResponse();
    if (response == null)
    {
      throw new IllegalStateException("newResponse() must not return null");
    }

    // and make it the current one
    requestCycle.setResponse(response);
  }
View Full Code Here


   * @see org.apache.wicket.behavior.AbstractBehavior#onRendered(org.apache.wicket.Component)
   */
  @Override
  public void onRendered(final Component component)
  {
    final RequestCycle requestCycle = RequestCycle.get();

    try
    {
      Response response = requestCycle.getResponse();

      // Transform the data
      CharSequence output = transform(component, response.toString());
      webResponse.write(output);
    }
    catch (Exception ex)
    {
      throw new WicketRuntimeException("Error while transforming the output: " + this, ex);
    }
    finally
    {
      // Restore the original response object
      requestCycle.setResponse(webResponse);
    }
  }
View Full Code Here

  @Override
  public void onException(Component component, RuntimeException exception)
  {
    if (webResponse != null)
    {
      final RequestCycle requestCycle = RequestCycle.get();
      requestCycle.setResponse(webResponse);
    }
  }
View Full Code Here

    }

    @Override
    protected void respond(AjaxRequestTarget target)
    {
      RequestCycle requestCycle = RequestCycle.get();
      boolean save = Boolean.valueOf(requestCycle.getRequest().getParameter("save"))
        .booleanValue();

      if (save)
      {
        editor.processInput();
View Full Code Here

          .getResponseRequestEncoding());

      try
      {
        // Create request cycle
        RequestCycle cycle = webApplication.newRequestCycle(request, response);

        try
        {
          // Process request
          cycle.request();
        }
        catch (AbortException e)
        {
          // noop
        }
View Full Code Here

   *            The url which describes the component path and the interface
   *            to be called.
   */
  private void dispatchEvent(final Page page, final String url)
  {
    RequestCycle rc = RequestCycle.get();
    IRequestCycleProcessor processor = rc.getProcessor();
    final RequestParameters requestParameters = processor.getRequestCodingStrategy().decode(
        new FormDispatchRequest(rc.getRequest(), url));
    IRequestTarget rt = processor.resolve(rc, requestParameters);
    if (rt instanceof ListenerInterfaceRequestTarget)
    {
      ListenerInterfaceRequestTarget interfaceTarget = ((ListenerInterfaceRequestTarget)rt);
      interfaceTarget.getRequestListenerInterface().invoke(page, interfaceTarget.getTarget());
View Full Code Here

      }

      AjaxLink link = (AjaxLink)linkComponent;

      setupRequestAndResponse();
      RequestCycle requestCycle = createRequestCycle();
      AjaxRequestTarget target = new AjaxRequestTarget();
      requestCycle.setRequestTarget(target);

      link.onClick(target);

      // process the request target
      target.respond(requestCycle);
    }
    // AjaxFallbackLinks is processed like an AjaxLink if isAjax is true
    // If it's not handling of the linkComponent is passed through to the
    // Link.
    else if (linkComponent instanceof AjaxFallbackLink && isAjax)
    {
      AjaxFallbackLink link = (AjaxFallbackLink)linkComponent;

      setupRequestAndResponse();
      RequestCycle requestCycle = createRequestCycle();
      AjaxRequestTarget target = new AjaxRequestTarget();
      requestCycle.setRequestTarget(target);

      link.onClick(target);

      // process the request target
      target.respond(requestCycle);
    }
    // if the link is an AjaxSubmitLink, we need to find the form
    // from it using reflection so we know what to submit.
    else if (linkComponent instanceof AjaxSubmitLink)
    {
      // If it's not ajax we fail
      if (isAjax == false)
      {
        fail("Link " + path + "is an AjaxSubmitLink and "
            + "will not be invoked when AJAX (javascript) is disabled.");
      }

      AjaxSubmitLink link = (AjaxSubmitLink)linkComponent;

      // We cycle through the attached behaviors and select the
      // LAST matching behavior as the one we handle.
      List behaviors = link.getBehaviors();
      AjaxFormSubmitBehavior ajaxFormSubmitBehavior = null;
      for (Iterator iter = behaviors.iterator(); iter.hasNext();)
      {
        Object behavior = iter.next();
        if (behavior instanceof AjaxFormSubmitBehavior)
        {
          AjaxFormSubmitBehavior submitBehavior = (AjaxFormSubmitBehavior)behavior;
          ajaxFormSubmitBehavior = submitBehavior;
        }
      }

      String failMessage = "No form submit behavior found on the submit link. Strange!!";
      notNull(failMessage, ajaxFormSubmitBehavior);

      setupRequestAndResponse();
      RequestCycle requestCycle = createRequestCycle();

      submitAjaxFormSubmitBehavior(ajaxFormSubmitBehavior);

      // Ok, finally we "click" the link
      ajaxFormSubmitBehavior.onRequest();

      // process the request target
      requestCycle.getRequestTarget().respond(requestCycle);
    }
    // if the link is a normal link (or ResourceLink)
    else if (linkComponent instanceof AbstractLink)
    {
      AbstractLink link = (AbstractLink)linkComponent;
View Full Code Here

    if (lockedRequest.isAjax() == true)
    {
      return true;
    }
   
    RequestCycle currentRequestCycle = RequestCycle.get();
    WebRequest currentRequest = (WebRequest) currentRequestCycle.getRequest();
   
    if (currentRequest.isAjax() == false)
    {
      // if this request is not ajax, we allow it
      return true;
    }
   
    String lockedPageId = Strings.firstPathComponent(lockedRequest.getRequestParameters().getComponentPath(), Component.PATH_SEPARATOR);
    String currentPageId = Strings.firstPathComponent(currentRequestCycle.getRequest().getRequestParameters().getComponentPath(), Component.PATH_SEPARATOR);
   
    int lockedVersion = lockedRequest.getRequestParameters().getVersionNumber();
    int currentVersion = currentRequest.getRequestParameters().getVersionNumber();
   
    if (currentPageId.equals(lockedPageId) && currentVersion == lockedVersion)
View Full Code Here

    }

    protected void respond(AjaxRequestTarget target)
    {
      RequestCycle requestCycle = RequestCycle.get();
      boolean save = Boolean.valueOf(requestCycle.getRequest().getParameter("save"))
          .booleanValue();

      if (save)
      {
        editor.processInput();
View Full Code Here

  /**
   * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#respond(org.apache.wicket.ajax.AjaxRequestTarget)
   */
  protected void respond(AjaxRequestTarget target)
  {
    final RequestCycle requestCycle = RequestCycle.get();
    final String val = requestCycle.getRequest().getParameter("q");
    onRequest(val, requestCycle);
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.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.