Examples of FormComponent


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

    if (formComponents != null && formComponents.length > 0)
    {
      Map args = new HashMap(formComponents.length * 3);
      for (int i = 0; i < formComponents.length; i++)
      {
        final FormComponent formComponent = formComponents[i];

        String arg = "label" + i;
        IModel label = formComponent.getLabel();
        if (label != null)
        {
          args.put(arg, label.getObject());
        }
        else
        {
          args.put(arg, formComponent.getLocalizer().getString(formComponent.getId(),
              formComponent.getParent(), formComponent.getId()));
        }

        args.put("input" + i, formComponent.getInput());
        args.put("name" + i, formComponent.getId());
      }
      return args;
    }
    else
    {
View Full Code Here

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

   *            index of the selectable option, starting from 0
   */
  public void select(String formComponentId, int index)
  {
    checkClosed();
    FormComponent component = (FormComponent)workingForm.get(formComponentId);

    ChoiceSelector choiceSelector = choiceSelectorFactory.create(component);
    choiceSelector.doSelect(index);
    if (component instanceof DropDownChoice)
    {
View Full Code Here

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

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

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

   *
   * @see org.apache.wicket.ajax.AjaxEventBehavior#onEvent(org.apache.wicket.ajax.AjaxRequestTarget)
   */
  protected final void onEvent(final AjaxRequestTarget target)
  {
    final FormComponent formComponent = getFormComponent();

    if (getEvent().toLowerCase().equals("onblur") && disableFocusOnBlur())
    {
      target.focusComponent(null);
    }

    try
    {
      formComponent.inputChanged();
      formComponent.validate();
      if (formComponent.hasErrorMessage())
      {
        formComponent.invalid();

        onError(target, null);
      }
      else
      {
        formComponent.valid();
        if (getUpdateModel())
        {
          formComponent.updateModel();
        }

        onUpdate(target);
      }
    }
View Full Code Here

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

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

    {
      @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

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

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

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

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

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

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

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

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