Package org.apache.wicket

Examples of org.apache.wicket.RequestCycle


        return page;
      }
    });

    // Setup the request. It should be a IMultipartWebRequest
    RequestCycle requestCycle = tester.createRequestCycle();
    MockHttpServletRequest servletRequest = tester.getServletRequest();
    servletRequest.setMethod("POST");
    servletRequest.setParameter("form2:hf:fs", "");
    servletRequest.setParameter("wicketState", "");
   
    File tmp = null;
    try {
      // Write out a large text file. We need to make this file reasonably sizable,
      // because things get handled using input streams, and we want to check to make
      // sure they're closed properly if we abort mid-request.
     
      // We create a temp file because we don't want to depend on a file we might not
      // know the path of (e.g. the big DTD this test used previously). This enables
      // us to run the test out of a JAR file if need be, and also with an unknown
      // running directory (e.g. when run from wicket-parent).
      tmp = new File(File.createTempFile(this.getClass().getName(), ".txt"));
      OutputStream os = new BufferedOutputStream(new FileOutputStream(tmp));
      for (int i = 0; i < 1000; i++)
      {
        os.write("test test test test test\n".getBytes());
      }
      os.close();
   
      // Let's upload the dtd file. It's large enough to avoid being in memory.
      servletRequest.addFile("upload", tmp, "text/plain");
 
      requestCycle.setRequest(new MultipartServletWebRequest(servletRequest, Bytes.MAX));

      // attach manually for the test
      field.attach();
     
      // Get the file upload
View Full Code Here


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


    };
    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

   * Continue to the location previous to this interception.
   */
  protected final void continueToPrevious()
  {
    // continue to original distination
    RequestCycle requestCycle = getRequestCycle();
    // Since we are explicitly redirecting to a page already, we do not
    // want a second redirect to occur automatically
    requestCycle.setRedirect(false);
    // Redirect there
    Response response = requestCycle.getResponse();
    response.reset();
    response.redirect(requestCycle.getRequest().getRelativePathPrefixToWicketHandler()
        + continueTo);
  }
View Full Code Here

          .getResponseRequestEncoding());

        createRequestContext(request, response);

        // Create request cycle
        final RequestCycle cycle = webApplication.newRequestCycle(request, response);

        try
        {
          // Process request
          cycle.request();

          return cycle.wasHandled();
        }
        catch (AbortException e)
        {
          // noop
        }
View Full Code Here

   * @param url
   *            The url which describes the component path and the interface to be called.
   */
  private void dispatchEvent(final Page page, final String url)
  {
    RequestCycle rc = RequestCycle.get();
    IRequestCycleProcessor processor = rc.getProcessor();
    final RequestParameters requestParameters = processor.getRequestCodingStrategy().decode(
      new FormDispatchRequest(rc.getRequest(), url));
    IRequestTarget rt = processor.resolve(rc, requestParameters);
    if (rt instanceof IListenerInterfaceRequestTarget)
    {
      IListenerInterfaceRequestTarget interfaceTarget = ((IListenerInterfaceRequestTarget)rt);
      interfaceTarget.getRequestListenerInterface().invoke(page, interfaceTarget.getTarget());
View Full Code Here

   *            the <code>Class</code> of the <code>Page</code> to be checked
   * @return true if the given <code>pageClass</code> is mounted, false otherwise
   */
  private boolean isPageMounted(Class<? extends Page> pageClass)
  {
    RequestCycle cycle = RequestCycle.get();
    CharSequence path = getRequestCodingStrategy().pathForTarget(
      new BookmarkablePageRequestTarget(pageClass));
    return path != null;
  }
View Full Code Here

   * @see org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy#matches(java.lang.String)
   */
  @Override
  public boolean matches(String path, boolean caseSensitive)
  {
    RequestCycle rc = RequestCycle.get();

    // the null check is necessary, as this method is first time called from WicketFilter when
    // no RequestCycle exists yet
    if (rc != null && ((WebRequest)rc.getRequest()).isAjax())
    {
      // HybridUrlCodingStrategy doesn't make sense for ajax request
      return false;
    }

View Full Code Here

   * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#respond(org.apache.wicket.ajax.AjaxRequestTarget)
   */
  @Override
  protected void respond(AjaxRequestTarget target)
  {
    final RequestCycle requestCycle = RequestCycle.get();
    final String val = requestCycle.getRequest().getParameter("q");
    onRequest(val, requestCycle);
  }
View Full Code Here

   * @return {@link AjaxRequestTarget} instance if current request is an Ajax request,
   *         <code>null</code> otherwise.
   */
  public static AjaxRequestTarget get()
  {
    final RequestCycle requestCycle = RequestCycle.get();
    if (requestCycle != null)
    {
      if (requestCycle.getRequestTarget() instanceof AjaxRequestTarget)
      {
        return (AjaxRequestTarget)requestCycle.getRequestTarget();
      }
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.RequestCycle

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.