Package org.apache.wicket.markup.html.form

Examples of org.apache.wicket.markup.html.form.TextField


      }
    };
    add(actionLink);
    actionLink.add(new Label("linkClickCount", new PropertyModel(this, "linkClickCount")));

    final TextField field = new TextField("textfield", new Model());

    StatelessForm statelessForm = new StatelessForm("statelessform")
    {
      private static final long serialVersionUID = 1L;

      /**
       * @see org.apache.wicket.markup.html.form.Form#onSubmit()
       */
      protected void onSubmit()
      {
        info("Submitted text: " + field.getDefaultModelObject() + ", link click count: " +
          linkClickCount);
      }
    };
    statelessForm.add(field);
    add(statelessForm);
View Full Code Here


      protected void onSubmit()
      {
        login(get("username").getDefaultModelObjectAsString().toString());
      }
    });
    form.add(textField = new TextField("username", new Model()));
  }
View Full Code Here

    // component properly set up (getRelativePath() etc.). See setUp().
    final Page page = application.getLastRenderedPage();

    // Get the form and form component created
    final TestForm form = (TestForm)page.get("form");
    final TextField textField = (TextField)form.get("input");

    // 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());

    // The persister to be used for the tests
    final CookieValuePersister persister = new CookieValuePersister();

    // See comment on CookieValuePersister on how clearing a value with
    // Cookies works. As no cookies in the request, no "delete" cookie
    // will be added to the response.
    persister.clear(textField);
    assertNull(getRequestCookies(cycle));
    assertEquals(0, getResponseCookies(cycle).size());

    // Save the input field's value (add it to the response's cookie list)
    persister.save(textField);
    assertNull(getRequestCookies(cycle));
    assertEquals(1, getResponseCookies(cycle).size());
    assertEquals("test", ((Cookie)getResponseCookies(cycle).get(0)).getValue());
    assertEquals("form:input", ((Cookie)getResponseCookies(cycle).get(0)).getName());
    assertEquals("/WicketTester$DummyWebApplication",
      ((Cookie)getResponseCookies(cycle).get(0)).getPath());

    // To clear in the context of cookies means to add a special cookie
    // (maxAge=0) to the response, provided a cookie with
    // the same name has been provided in the request. Thus, no changes in
    // our test case
    persister.clear(textField);
    assertNull(getRequestCookies(cycle));
    assertEquals(1, getResponseCookies(cycle).size());
    assertEquals("test", ((Cookie)getResponseCookies(cycle).get(0)).getValue());
    assertEquals("form:input", ((Cookie)getResponseCookies(cycle).get(0)).getName());
    assertEquals("/WicketTester$DummyWebApplication",
      ((Cookie)getResponseCookies(cycle).get(0)).getPath());

    // Try to load it. Because there is no Cookie matching the textfield's name
    // it remains unchanged
    persister.load(textField);
    assertEquals("test", textField.getDefaultModelObjectAsString());

    // Simulate loading a textfield. Initialize textfield with a new
    // (default) value, copy the cookie from respone to request (simulating
    // a browser), than load the textfield from cookie and voala the
    // textfields value should change.
    // save means: add it to the respone
    // load means: take it from request
    assertEquals("test", textField.getDefaultModelObjectAsString());
    textField.setDefaultModelObject("new text");
    assertEquals("new text", textField.getDefaultModelObjectAsString());
    copyCookieFromResponseToRequest(cycle);
    assertEquals(1, getRequestCookies(cycle).length);
    assertEquals(1, getResponseCookies(cycle).size());

    persister.load(textField);
    assertEquals("test", textField.getDefaultModelObjectAsString());
    assertEquals(1, getRequestCookies(cycle).length);
    assertEquals(1, getResponseCookies(cycle).size());

    // remove all cookies from mock response
    // Because I'll find the cookie to be removed in the request, the
View Full Code Here

      // create components

      RootSubSegmentsModel rootSubSegmentsModel = new RootSubSegmentsModel();

      DropDownChoice rootSubSegmentsDropDownChoice;
      TextField queryTextField;

      rootSubSegmentsDropDownChoice = new DropDownChoice("rootSubSegment", rootSubSegmentsModel, (IChoiceRenderer) rootSubSegmentsModel);
      rootSubSegmentsDropDownChoice.setLabel(new Model("Root namespace"));
      rootSubSegmentsDropDownChoice.setRequired(true);

      queryTextField = new TextField("query");
      queryTextField.setLabel(new Model("Query"));
      queryTextField.setRequired(true);

      // create and add components

      this.add(rootSubSegmentsDropDownChoice);
      this.add(queryTextField);
View Full Code Here

      super(id);
      this.setModel(new CompoundPropertyModel(this));

      // create and add components

      this.add(new TextField("xri"));
    }
View Full Code Here

      super(id);
      this.setModel(new CompoundPropertyModel(this));

      // create and add components

      this.add(new TextField("xri"));
    }
View Full Code Here

      super(id);
      this.setModel(new CompoundPropertyModel(this));

      // create and add components

      this.add(new TextField("pth").setLabel(new Model("Mount Path")).setRequired(true));
    }
View Full Code Here

      super(id);
      this.setModel(new CompoundPropertyModel(this));

      // create and add components

      this.add(new TextField("namespace").setRequired(true));
    }
View Full Code Here

      super(id);
      this.setModel(new CompoundPropertyModel(this));

      // create and add components

      this.add(new TextField("xri"));
    }
View Full Code Here

      super(id);
      this.setModel(new CompoundPropertyModel(this));

      // create and add components

      this.add(new TextField("xri"));
    }
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.html.form.TextField

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.