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

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


        Form form = tester.getForm();
        form.visitChildren(new Component.IVisitor() {
           
            public Object component(Component component) {
                if(component instanceof FormComponent) {
                    FormComponent fc = (FormComponent) component;
                    String name = fc.getInputName();
                    String value = fc.getValue();
                   
                    tester.setValue(name, value);
                }
                return Component.IVisitor.CONTINUE_TRAVERSAL;
            }
View Full Code Here


   *            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

   */
  public void setValue(final String formComponentId, final String value)
  {
    checkClosed();

    FormComponent formComponent = (FormComponent)workingForm.get(formComponentId);
    setFormComponentValue(formComponent, value);
  }
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

   *
   * @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();
        formComponent.updateModel();

        onUpdate(target);
      }
    }
    catch (RuntimeException e)
View Full Code Here

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

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

        onError(target, null);
      }
      else
      {
        formComponent.valid();
        formComponent.updateModel();
        onUpdate(target);
      }
    }
    catch (RuntimeException e)
    {
View Full Code Here

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

    try
    {
      formComponent.inputChanged();
      formComponent.validate();
      if (formComponent.hasErrorMessage())
      {
        formComponent.invalid();
       
        onError(target, null);
      }
      else
      {
        formComponent.valid();
        formComponent.updateModel();
        onUpdate(target);
      }
    }
    catch (RuntimeException e)
    {
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

   *            index of selectable option, start 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

   */
  public void setValue(final String formComponentId, final String value)
  {
    checkClosed();

    FormComponent formComponent = (FormComponent)workingForm.get(formComponentId);
    setFormComponentValue(formComponent, value);
  }
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.