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

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


  {
    // initialize
    this.form.loadPersistentFormComponentValues();

    // validate
    FormComponent username = (FormComponent)panel.get("signInForm:username");

    Assert.assertNotNull(username);

    Assert.assertNotNull(cookieUsername);

    Assert.assertEquals(cookieUsername.getValue(), username.getModelObjectAsString());
  }
View Full Code Here


    {
      @SuppressWarnings("unchecked")
      @Override
      public void onFormComponent(FormComponent<?> formComponent2, IVisit<Void> visit)
      {
        final FormComponent formComponent=formComponent2;
        // do nothing for invisible component
        if (!formComponent.isVisibleInHierarchy())
        {
          return;
        }

        // if component is text field and do not have exist value, fill
        // blank String if required
        if (formComponent instanceof AbstractTextComponent)
        {
          if (Strings.isEmpty(formComponent.getValue()))
          {
            if (fillBlankString)
            {
              setFormComponentValue(formComponent, "");
            }
          }
          else
          {
            setFormComponentValue(formComponent, formComponent.getValue());
          }
        }
        else if ((formComponent instanceof DropDownChoice) ||
          (formComponent instanceof RadioChoice) || (formComponent instanceof CheckBox))
        {
          setFormComponentValue(formComponent, formComponent.getValue());
        }
        else if (formComponent instanceof ListMultipleChoice)
        {
          final String[] modelValues = formComponent.getValue().split(
            FormComponent.VALUE_SEPARATOR);
          for (String modelValue : modelValues)
          {
            addFormComponentValue(formComponent, modelValue);
          }
        }
        else if (formComponent instanceof CheckGroup)
        {
          final Collection<?> checkGroupValues = (Collection<?>)formComponent.getDefaultModelObject();
          formComponent.visitChildren(Check.class, new IVisitor<Component, Void>()
          {
            public void component(final Component component, final IVisit<Void> visit)
            {
              if (checkGroupValues.contains(component.getDefaultModelObject()))
              {
                addFormComponentValue(formComponent,
                  ((Check<?>)component).getValue());
              }
            }
          });
        }
        else if (formComponent instanceof RadioGroup)
        {
          // TODO 1.5: see if all these transformations can be factored out into
          // checkgroup/radiogroup by them implementing some sort of interface {
          // getValue(); } otherwise all these implementation details leak into the tester
          final Object value = formComponent.getDefaultModelObject();
          if (value != null)
          {
            formComponent.visitChildren(Radio.class, new IVisitor<Component, Void>()
            {
              public void component(final Component component,
                final IVisit<Void> visit)
              {
                if (value.equals(component.getDefaultModelObject()))
View Full Code Here

   */
  public void setFile(final String formComponentId, final File file, final String contentType)
  {
    checkClosed();

    FormComponent formComponent = (FormComponent)workingForm.get(formComponentId);

    if (formComponent instanceof FileUploadField == false)
    {
      throw new IllegalArgumentException("'" + formComponentId + "' is not " +
        "a FileUploadField. You can only attach a file to form " +
        "component of this type.");
    }

    MockHttpServletRequest servletRequest = tester.getRequest();
    servletRequest.addFile(formComponent.getInputName(), file, contentType);
  }
View Full Code Here

    // add form with markup id setter so it can be updated via ajax
    Form<Bean> form = new Form<Bean>("form", new CompoundPropertyModel<Bean>(bean));
    add(form);
    form.setOutputMarkupId(true);

    FormComponent fc;

    // add form components to the form as usual

    fc = new RequiredTextField<String>("name");
    fc.add(StringValidator.minimumLength(4));
    fc.setLabel(new ResourceModel("label.name"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("name-label", fc));

    fc = new RequiredTextField<String>("email");
    fc.add(EmailAddressValidator.getInstance());
    fc.setLabel(new ResourceModel("label.email"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("email-label", fc));

    // attach an ajax validation behavior to all form component's onkeydown
View Full Code Here

    // add form with markup id setter so it can be updated via ajax
    Form form = new Form("form", new CompoundPropertyModel(bean));
    add(form);
    form.setOutputMarkupId(true);

    FormComponent fc;

    // add form components to the form as usual

    fc = new RequiredTextField("name");
    fc.add(StringValidator.minimumLength(4));
    fc.setLabel(new ResourceModel("label.name"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("name-label", fc));

    fc = new RequiredTextField("email");
    fc.add(EmailAddressValidator.getInstance());
    fc.setLabel(new ResourceModel("label.email"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("email-label", fc));

    // attach an ajax validation behavior to all form component's onkeydown
View Full Code Here

    // add form with markup id setter so it can be updated via ajax
    Form<Bean> form = new Form<Bean>("form", new CompoundPropertyModel<Bean>(bean));
    add(form);
    form.setOutputMarkupId(true);

    FormComponent fc;

    // add form components to the form as usual

    fc = new RequiredTextField<String>("name");
    fc.add(StringValidator.minimumLength(4));
    fc.setLabel(new ResourceModel("label.name"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("name-label", fc));

    fc = new RequiredTextField<String>("email");
    fc.add(EmailAddressValidator.getInstance());
    fc.setLabel(new ResourceModel("label.email"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("email-label", fc));

    // attach an ajax validation behavior to all form component's onkeydown
View Full Code Here

   */
  public void setFile(final String formComponentId, final File file, final String contentType)
  {
    checkClosed();

    FormComponent formComponent = (FormComponent)workingForm.get(formComponentId);

    if (formComponent instanceof FileUploadField == false)
    {
      throw new IllegalArgumentException("'" + formComponentId + "' is not " +
        "a FileUploadField. You can only attach a file to form " +
        "component of this type.");
    }

    MockHttpServletRequest servletRequest = baseWicketTester.getServletRequest();
    servletRequest.addFile(formComponent.getInputName(), file, contentType);
  }
View Full Code Here

            feedback.setOutputMarkupId(true);
            add(feedback);
            this.metaData = jmetaData;
            this.oldMetaData = jmetaData;
            Form metaDataForm = new Form("metaDataForm");
            FormComponent fc;
            fc = new RequiredTextField("name", new PropertyModel(this,
                    "metaData.name"));
            fc.add(StringValidator.minimumLength(2));
            metaDataForm.add(fc);
            metaDataForm.add(new Label("name-label", new ResourceModel(
                    "metedataTab.name")));
            fc = new RequiredTextField("language", new PropertyModel(this,
                    "metaData.language"));
            fc.add(StringValidator.minimumLength(2));
            metaDataForm.add(fc);
            metaDataForm.add(new Label("language-label", new ResourceModel(
                    "metedataTab.language")));
            fc = new RequiredTextField("metaValue", new PropertyModel(this,
                    "metaData.value"));
            fc.add(StringValidator.minimumLength(2));
            metaDataForm.add(fc);
            metaDataForm.add(new Label("value-label", new ResourceModel(
                    "metedataTab.value")));
            metaDataForm.add(new AjaxButton("save", new ResourceModel(
                    "common.save"), metaDataForm)
View Full Code Here

    Bean bean = new Bean();
    Form<Bean> form = new Form<>("form", new CompoundPropertyModel<>(bean));
    add(form);
    form.setOutputMarkupId(true);

    FormComponent fc;

    // add form components to the form as usual

    fc = new RequiredTextField<>("name");
    fc.add(new StringValidator(4, null));
    fc.setLabel(new ResourceModel("label.name"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("name-label", fc));

    fc = new RequiredTextField<>("email");
    fc.add(EmailAddressValidator.getInstance());
    fc.setLabel(new ResourceModel("label.email"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("email-label", fc));

    // attach an ajax validation behavior to all form component's keydown
View Full Code Here

    Bean bean = new Bean();
    Form<Bean> form = new Form<Bean>("form", new CompoundPropertyModel<Bean>(bean));
    add(form);
    form.setOutputMarkupId(true);

    FormComponent fc;

    // add form components to the form as usual

    fc = new RequiredTextField<String>("name");
    fc.add(new StringValidator(4, null));
    fc.setLabel(new ResourceModel("label.name"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("name-label", fc));

    fc = new RequiredTextField<String>("email");
    fc.add(EmailAddressValidator.getInstance());
    fc.setLabel(new ResourceModel("label.email"));

    form.add(fc);
    form.add(new SimpleFormComponentLabel("email-label", fc));

    // attach an ajax validation behavior to all form component's keydown
View Full Code Here

TOP

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

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.