Examples of WebRequestCycle


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

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

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

  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

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

       */
      protected void onSubmit()
      {
        ClientPropertiesBean propertiesBean = (ClientPropertiesBean)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

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

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

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

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

{
  private static SecureRandom numberGenerator;

  public ICrypt newCrypt()
  {
    WebRequestCycle rc = (WebRequestCycle)RequestCycle.get();

    // get http session, create if necessary
    HttpSession session = rc.getWebRequest().getHttpServletRequest().getSession(true);

    // retrieve or generate encryption key from session
    final String keyAttr = rc.getApplication().getApplicationKey() + "." + getClass().getName();
    String key = (String)session.getAttribute(keyAttr);
    if (key == null)
    {
      // generate new key
      key = session.getId() + "." + randomUUIDString();
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

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

      // we don't want to render this for stateless pages
      if (webPage.isPageStateless())
      {
        return;
      }

      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("wicket-" + 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 intermingle 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

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

    requestHandlingOfResourceUrlWithEscapeStringInside();
  }

  private void requestHandlingOfResourceUrlWithEscapeStringInside()
  {
    final WebRequestCycle cycle = tester.setupRequestAndResponse();
    final MockHttpServletRequest request = tester.getServletRequest();
    request.setMethod("GET");
    request.setURL("http://localhost/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/" +
      expectedResourceUrl());
    tester.processRequestCycle(cycle);
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.