Examples of WebRequestCycle


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

   */
  public void testDetachAttachNormalModel() throws Exception
  {
    StringResourceModel model = new StringResourceModel("simple.text", page, wsModel);
    tester.setupRequestAndResponse();
    RequestCycle cycle = new WebRequestCycle(tester.getApplication(),
      tester.getWicketRequest(), tester.getWicketResponse());
    model.getObject();
    Assert.assertNotNull(model.getLocalizer());
    model.detach();
    Assert.assertNull(model.getLocalizer());
View Full Code Here

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


    };
    StringResourceModel model = new StringResourceModel("simple.text", page, wsDetachModel);
    tester.setupRequestAndResponse();
    RequestCycle cycle = new WebRequestCycle(tester.getApplication(),
      tester.getWicketRequest(), tester.getWicketResponse());
    model.getObject();
    Assert.assertNotNull(model.getLocalizer());
    model.detach();
    // Removed this because getObject() will reattach now...
View Full Code Here

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

      @Override
      protected void onSubmit()
      {
        ClientPropertiesBean propertiesBean = getModelObject();

        WebRequestCycle requestCycle = (WebRequestCycle)getRequestCycle();
        WebSession session = (WebSession)getSession();
        ClientInfo clientInfo = session.getClientInfo();

        if (clientInfo == null)
        {
View Full Code Here

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

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

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

      }

      AjaxLink link = (AjaxLink)linkComponent;

      setupRequestAndResponse(true);
      WebRequestCycle requestCycle = createRequestCycle();
      callOnBeginRequest(requestCycle);
      AjaxRequestTarget target = new AjaxRequestTarget(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 = new AjaxRequestTarget(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);

      setupRequestAndResponse(true);
      WebRequestCycle requestCycle = createRequestCycle();

      submitAjaxFormSubmitBehavior(ajaxFormSubmitBehavior);

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

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

    notNull(failMessage, ajaxEventBehavior);

    // 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(true);
    }
    else
    {
      requestCycle = (WebRequestCycle)RequestCycle.get();
    }
    // when the requestcycle is not created via setupRequestAndResponse(true), it can happen
    // that the request is not an ajax request -> we have to set the header manually
    if (!requestCycle.getWebRequest().isAjax())
    {
      HttpServletRequest req = requestCycle.getWebRequest().getHttpServletRequest();
      if (req instanceof MockHttpServletRequest)
      {
        ((MockHttpServletRequest)req).addHeader("Wicket-Ajax", "Yes");
      }
    }
View Full Code Here

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

    // Make sure a valid cycle is available through RequestCycle.get().
    // The RequestCycle's constructor will attach the new cycle to
    // the threadLocal retrieved by RequestCycle.get().
    // Attached to this cycle must be a valid request and response
    final WebRequestCycle cycle = application.createRequestCycle();

    // Just after init, the requests and responses cookie lists must be
    // empty
    assertNull(getRequestCookies(cycle));
    assertEquals(0, getResponseCookies(cycle).size());
View Full Code Here

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

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

   *            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

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

      }

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

      setupRequestAndResponse(true);
      WebRequestCycle requestCycle = createRequestCycle();
      callOnBeginRequest(requestCycle);
      AjaxRequestTarget target = new AjaxRequestTarget(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 = new AjaxRequestTarget(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(ajaxFormSubmitBehavior);

      // Ok, finally we "click" the link
      ajaxFormSubmitBehavior.onRequest();
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.