Package org.apache.wicket.protocol.http

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


   *      org.apache.wicket.Response)
   */
  @Override
  public RequestCycle newRequestCycle(Request request, Response response)
  {
    return new WebRequestCycle(this, (WebRequest)request, response)
    {
      @Override
      protected void onBeginRequest()
      {
        // open session
View Full Code Here


   *            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

      }

      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

    // If there haven't been found any event behaviors on the component
    // which matches the parameters we fail.
    failMessage = "No AjaxEventBehavior found on component: " + component.getId() +
      " which matches the event: " + event;
    notNull(failMessage, ajaxEventBehavior);
    WebRequestCycle requestCycle = resolveRequestCycle();

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

  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(true);
    }
    else
View Full Code Here

    checkClosed();
    try
    {
      MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();

      WebRequestCycle requestCycle = baseWicketTester.createRequestCycle();
      servletRequest.setRequestToComponent(workingForm);

      servletRequest.setUseMultiPartContentType(isMultiPart());
      baseWicketTester.processRequestCycle(requestCycle);
    }
View Full Code Here

    assertEquals(((MyMockWebApplication)application.getApplication()).getLoginPage(),
      loginPage.getClass());

    // bypass form completely to login but continue to intercept page
    application.setupRequestAndResponse();
    WebRequestCycle requestCycle = application.createRequestCycle();
    assertTrue(((MockLoginPage)application.getLastRenderedPage()).login("admin"));
    application.processRequestCycle(requestCycle);

    assertEquals(application.getApplication().getHomePage(), application.getLastRenderedPage()
      .getClass());
View Full Code Here

   *
   */
  public void test1()
  {
    tester.setupRequestAndResponse();
    WebRequestCycle cycle = tester.createRequestCycle();
    cycle.getSession().setLocale(Locale.ENGLISH);

    // test English/ default

    TestPage page = new TestPage();
    Form form = (Form)page.get("form1");
    assertNotNull(form);

    page.getText1().setInput("");
    page.getText1().validateRequired();
    page.getText2().setInput("");
    page.getText2().validateRequired();
    page.getText3().setInput("");
    page.getText3().validateRequired();
    page.getText4().setInput("");
    page.getText4().validateRequired();
    page.getText5().setInput("");
    page.getText5().validateRequired();
    page.getText6().setInput("");
    page.getText6().validateRequired();
    page.getText7().setInput("");
    page.getText7().validateRequired();
    page.getText8().setInput("");
    page.getText8().validateRequired();
    page.getText9().setInput("");
    page.getText9().validateRequired();
    page.getText10().setInput("");
    page.getText10().validateRequired();
    page.getText11().setInput("");
    page.getText11().validateRequired();
    page.getText12().setInput("");
    page.getText12().validateRequired();

    assertEquals("text1label is required", page.getText1()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("text2 is required", page.getText2()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("ok: text3333 is missing", page.getText3()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("ok: Text4Label is missing", page.getText4()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("ok: text is missing", page.getText5()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text6 required", page.getText6()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("input for text7-Label is missing", page.getText7()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text8-Label required", page.getText8()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("found it in panel", page.getText9()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("found it in form", page.getText10()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("found it in page", page.getText11()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("found it in page", page.getText12()
      .getFeedbackMessage()
      .getMessage()
      .toString());

    // Test caching
    assertEquals("Default message: text8-Label required", page.getText8()
      .getFeedbackMessage()
      .getMessage()
      .toString());

    // now test Dutch

    cycle.getSession().setLocale(new Locale("nl"));
    page = new TestPage();
    form = (Form)page.get("form1");
    assertNotNull(form);

    page.getText1().setInput("");
View Full Code Here

   */
  public void test2()
  {
    tester.getApplication().getResourceSettings().setThrowExceptionOnMissingResource(false);
    tester.setupRequestAndResponse();
    WebRequestCycle cycle = tester.createRequestCycle();

    String str = tester.getApplication().getResourceSettings().getLocalizer().getString("XXX",
      null);
    assertEquals("[Warning: Property for 'XXX' not found]", str);
  }
View Full Code Here

   */
  public void test3()
  {
    tester.getApplication().getResourceSettings().setThrowExceptionOnMissingResource(true);
    tester.setupRequestAndResponse();
    WebRequestCycle cycle = tester.createRequestCycle();

    boolean hit = false;
    try
    {
      tester.getApplication().getResourceSettings().getLocalizer().getString("XXX", null);
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.