Package org.apache.wicket.protocol.http

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


    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

    assertEquals("1", tester.getWicketSession().getPageMaps().get(2).getName());
  }

  private void goToPage(Class<?> pageClass, String pageMap)
  {
    WebRequestCycle cycle = tester.setupRequestAndResponse();
    tester.getServletRequest().setParameter(
      WebRequestCodingStrategy.BOOKMARKABLE_PAGE_PARAMETER_NAME,
      pageMap + ':' + pageClass.getName());
    tester.processRequestCycle(cycle);
    tester.assertRenderedPage(TestPage.class);
View Full Code Here

    this.cookiePassword = new Cookie("panel:signInForm:password", encryptedPassword);
    this.cookies = new Cookie[] { cookieUsername, cookiePassword };

    tester.getServletRequest().setCookies(cookies);

    cycle = new WebRequestCycle(tester.getApplication(), tester.getWicketRequest(), tester
        .getWicketResponse());

    this.page = new MockPage(null);
    page.add(this.panel);

    WebRequestCycle cycle = new WebRequestCycle(tester.getApplication(), tester
        .getWicketRequest(), tester.getWicketResponse());
  }
View Full Code Here

     * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.Response)
     */
    public final void renderHead(final IHeaderResponse headResponse)
    {
      Response response = headResponse.getResponse();
      final WebRequestCycle cycle = (WebRequestCycle)RequestCycle.get();
      final IRequestTarget target = cycle.getRequestTarget();

      IPageMap pageMap = webPage.getPageMap();
      String name = pageMap.getName();
      if (name == null)
      {
        name = "wicket:default";
      }
      else
      {
        name = name.replace('"', '_');
      }

      Session session = Session.get();

      Session.PageMapAccessMetaData meta = (Session.PageMapAccessMetaData)session
          .getMetaData(Session.PAGEMAP_ACCESS_MDK);
      if (meta == null)
      {
        meta = new Session.PageMapAccessMetaData();
        session.setMetaData(Session.PAGEMAP_ACCESS_MDK, meta);
      }
      boolean firstAccess = meta.add(pageMap);

      if (firstAccess)
      {
        // this is the first access to the pagemap, set window.name
        JavascriptUtils.writeOpenTag(response);
        response
            .write("if (window.name=='' || window.name.indexOf('wicket') > -1) { window.name=\"");
        response.write(name);
        response.write("\"; }");
        JavascriptUtils.writeCloseTag(response);
      }
      else
      {
        // Here is our trickery to detect whether the current request
        // was
        // made in a new window/ tab, in which case it should go in a
        // different page map so that we don't intermangle the history
        // of
        // those windows
        CharSequence url = null;
        if (target instanceof IBookmarkablePageRequestTarget)
        {
          IBookmarkablePageRequestTarget current = (IBookmarkablePageRequestTarget)target;
          BookmarkablePageRequestTarget redirect = new BookmarkablePageRequestTarget(
              session.createAutoPageMapName(), current.getPageClass(), current
                  .getPageParameters());
          url = cycle.urlFor(redirect);
        }
        else
        {
          url = webPage.urlFor(INewBrowserWindowListener.INTERFACE);
        }
View Full Code Here

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

    failMessage = "No AjaxEventBehavior found on component: " + component.getId()
        + " which matches the event: " + event.toString();
    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();
    else
      requestCycle = (WebRequestCycle)RequestCycle.get();
View Full Code Here

  {
    checkClosed();
    try
    {
      MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
      WebRequestCycle requestCycle = baseWicketTester.createRequestCycle();
      servletRequest.setRequestToComponent(workingForm);

      if (servletRequest.hasUploadedFiles())
      {
        requestCycle.setRequest(new MultipartServletWebRequest(servletRequest, workingForm
            .getMaxSize()));
      }

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

    this.cookiePassword = new Cookie("panel:signInForm:password", encryptedPassword);
    this.cookies = new Cookie[] { cookieUsername, cookiePassword };

    tester.getServletRequest().setCookies(cookies);

    cycle = new WebRequestCycle(tester.getApplication(), tester.getWicketRequest(), tester
        .getWicketResponse());

    this.page = new MockPage(null);
    page.add(this.panel);

    WebRequestCycle cycle = new WebRequestCycle(tester.getApplication(), tester
        .getWicketRequest(), tester.getWicketResponse());
  }
View Full Code Here

   *
   */
  public void test_1()
  {
    tester.setupRequestAndResponse();
    WebRequestCycle cycle = tester.createRequestCycle();
    TestPage page = new TestPage();
    cycle.getSession().setLocale(Locale.GERMANY);
    cycle.getSession().setStyle("mystyle");

    String str = page.getString("test1");
    str = page.getString("test2");
    str = page.getString("test3");
    str = page.getString("test4");
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.