Package org.apache.wicket.protocol.http

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


    // first, render page with no style
    executeTest(MarkupInheritanceExtension_1.class, "MarkupInheritanceExpectedResult_1.html");

    // then, render with style1
    tester.setupRequestAndResponse();
    WebRequestCycle cycle = tester.createRequestCycle();
    cycle.getSession().setStyle("style1");
    tester.startPage(MarkupInheritanceExtension_1.class);
    tester.assertRenderedPage(MarkupInheritanceExtension_1.class);
    tester.assertResultPage(getClass(), "MarkupInheritanceExpectedResult_1_style1.html");

    // then, render with style2
    tester.setupRequestAndResponse();
    cycle = tester.createRequestCycle();
    cycle.getSession().setStyle("style2");
    tester.startPage(MarkupInheritanceExtension_1.class);
    tester.assertRenderedPage(MarkupInheritanceExtension_1.class);
    tester.assertResultPage(getClass(), "MarkupInheritanceExpectedResult_1_style2.html");
  }
View Full Code Here


    {
      baseWicketTester.getWicketSession().cleanupFeedbackMessages();

      MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();

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

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

  /**
   *
   */
  public void test1()
  {
    WebRequestCycle cycle = tester.setupRequestAndResponse();
    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();
    page.getText13().setInput("");
    page.getText13().validateRequired();
    page.getText14().setInput("");
    page.getText14().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("Default message: text5 required", page.getText5()
    // assertEquals("ok: 555text555 is missing", page.getText5()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text6 required", page.getText6()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text7-Label required", page.getText7()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text8-Label required", page.getText8()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text9 required", page.getText9()
    // assertEquals("found it in panel", page.getText9()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text10 required", page.getText10()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("found it in page", page.getText11()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text12 required", page.getText12()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("found text-13 property", page.getText13()
      .getFeedbackMessage()
      .getMessage()
      .toString());
    assertEquals("Default message: text14 required", page.getText14()
      .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

      @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

     */
    @Override
    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.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

   * @throws Exception
   */
  public void testDefault() throws Exception
  {
    tester.setupRequestAndResponse();
    WebRequestCycle cycle = tester.createRequestCycle();
    cycle.getSession().setLocale(Locale.ENGLISH);
    tester.startPage(Page1.class);
    tester.assertRenderedPage(Page1.class);
    tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_expected.html");
  }
View Full Code Here

   * @throws Exception
   */
  public void testDutch() throws Exception
  {
    tester.setupRequestAndResponse();
    WebRequestCycle cycle = tester.createRequestCycle();
    cycle.getSession().setLocale(new Locale("nl"));
    tester.startPage(Page1.class);
    tester.assertRenderedPage(Page1.class);
    tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_nl_expected.html");
  }
View Full Code Here

   * @throws Exception
   */
  public void testDutchMyStyle() throws Exception
  {
    tester.setupRequestAndResponse();
    WebRequestCycle cycle = tester.createRequestCycle();
    cycle.getSession().setLocale(new Locale("nl"));
    cycle.getSession().setStyle("mystyle");
    tester.startPage(Page1.class);
    tester.assertRenderedPage(Page1.class);
    tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_mystyle_nl_expected.html");
  }
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.