Package org.apache.wicket.protocol.http

Examples of org.apache.wicket.protocol.http.WebRequestCycle


   * @param component
   *            the listener to invoke
   */
  public void executeListener(Component component)
  {
    WebRequestCycle cycle = setupRequestAndResponse();
    getServletRequest().setRequestToComponent(component);
    processRequestCycle(cycle);
  }
View Full Code Here


   *            an <code>AbstractAjaxBehavior</code> to execute
   */
  public void executeBehavior(final AbstractAjaxBehavior behavior)
  {
    CharSequence url = behavior.getCallbackUrl(false);
    WebRequestCycle cycle = setupRequestAndResponse(true);
    getServletRequest().setRequestToRedirectString(url.toString());
    processRequestCycle(cycle);
  }
View Full Code Here

      }

      AjaxLink<?> link = (AjaxLink<?>)linkComponent;

      setupRequestAndResponse(true);
      WebRequestCycle requestCycle = createRequestCycle();
      AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage());
      requestCycle.setRequestTarget(target);

      link.onClick(target);

      // process the request target
      processRequestCycle(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(true);
      WebRequestCycle requestCycle = createRequestCycle();
      AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage());
      requestCycle.setRequestTarget(target);

      link.onClick(target);

      // process the request target
      processRequestCycle(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<IBehavior> behaviors = link.getBehaviors();
      AjaxFormSubmitBehavior ajaxFormSubmitBehavior = null;
      for (IBehavior behavior : behaviors)
      {
        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);

      WebRequestCycle requestCycle = setupRequestAndResponse(true);

      submitAjaxFormSubmitBehavior(linkComponent, ajaxFormSubmitBehavior);

      // Ok, finally we "click" the link
      ajaxFormSubmitBehavior.onRequest();
View Full Code Here

      " which matches the event: " + event;
    notNull(failMessage, ajaxEventBehavior);

    // when the requestcycle is not created via setupRequestAndResponse(true), than create a new
    // one
    WebRequestCycle requestCycle = resolveRequestCycle();
    if (!requestCycle.getWebRequest().isAjax())
    {
      throw new IllegalStateException(
        "The ServletWebRequest was created without wicket-ajax header. Please use tester.setCreateAjaxRequest(true)");
    }
View Full Code Here

   */
  protected WebRequestCycle resolveRequestCycle()
  {
    // initialize the request only if needed to allow the user to pass
    // request parameters, see WICKET-254
    WebRequestCycle requestCycle;
    if (RequestCycle.get() == null)
    {
      requestCycle = setupRequestAndResponse();
    }
    else
    {
      requestCycle = (WebRequestCycle)RequestCycle.get();

      // If a ajax request is requested but the existing is not, than we still need to create
      // a new one
      if ((requestCycle.getWebRequest().isAjax() == false) && (isCreateAjaxRequest() == true))
      {
        setParametersForNextRequest(requestCycle.getWebRequest().getParameterMap());
        requestCycle = setupRequestAndResponse();
      }
    }
    return requestCycle;
  }
View Full Code Here

   * @param component
   *            the listener to invoke
   */
  public void executeListener(Component component)
  {
    WebRequestCycle cycle = setupRequestAndResponse();
    getServletRequest().setRequestToComponent(component);
    processRequestCycle(cycle);
  }
View Full Code Here

   *            an <code>AbstractAjaxBehavior</code> to execute
   */
  public void executeBehavior(final AbstractAjaxBehavior behavior)
  {
    CharSequence url = behavior.getCallbackUrl(false);
    WebRequestCycle cycle = setupRequestAndResponse(true);
    getServletRequest().setRequestToRedirectString(url.toString());
    processRequestCycle(cycle);
  }
View Full Code Here

      }

      AjaxLink<?> link = (AjaxLink<?>)linkComponent;

      setupRequestAndResponse(true);
      WebRequestCycle requestCycle = createRequestCycle();
      callOnBeginRequest(requestCycle);
      AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage());
      requestCycle.setRequestTarget(target);

      link.onClick(target);

      // process the request target
      processRequestCycle(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(true);
      WebRequestCycle requestCycle = createRequestCycle();
      AjaxRequestTarget target = getApplication().newAjaxRequestTarget(link.getPage());
      requestCycle.setRequestTarget(target);

      link.onClick(target);

      // process the request target
      processRequestCycle(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<IBehavior> behaviors = link.getBehaviors();
      AjaxFormSubmitBehavior ajaxFormSubmitBehavior = null;
      for (IBehavior behavior : behaviors)
      {
        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);

      WebRequestCycle requestCycle = setupRequestAndResponse(true);

      submitAjaxFormSubmitBehavior(linkComponent, ajaxFormSubmitBehavior);

      // Ok, finally we "click" the link
      ajaxFormSubmitBehavior.onRequest();
View Full Code Here

      " which matches the event: " + event;
    notNull(failMessage, ajaxEventBehavior);

    // when the requestcycle is not created via setupRequestAndResponse(true), than create a new
    // one
    WebRequestCycle requestCycle = resolveRequestCycle();
    if (!requestCycle.getWebRequest().isAjax())
    {
      throw new IllegalStateException(
        "The ServletWebRequest was created without wicket-ajax header. Please use tester.setCreateAjaxRequest(true)");
    }
View Full Code Here

   */
  protected WebRequestCycle resolveRequestCycle()
  {
    // initialize the request only if needed to allow the user to pass
    // request parameters, see WICKET-254
    WebRequestCycle requestCycle;
    if (RequestCycle.get() == null)
    {
      requestCycle = setupRequestAndResponse();
    }
    else
    {
      requestCycle = (WebRequestCycle)RequestCycle.get();

      // If a ajax request is requested but the existing is not, than we still need to create
      // a new one
      if ((requestCycle.getWebRequest().isAjax() == false) && (isCreateAjaxRequest() == true))
      {
        setParametersForNextRequest(requestCycle.getWebRequest().getParameterMap());
        requestCycle = setupRequestAndResponse();
      }
    }
    return requestCycle;
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.protocol.http.WebRequestCycle

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.