You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris Carlson <ch...@carlsoncentral.com> on 2009/04/07 04:26:28 UTC

Custom validation

New to wicket trying to figure out the best way to do custom validation. I
have a dropdown and a textfield, only 1 of which is required.  I want the
user to select from the dropdown, and if their option is not listed, be
able to enter anything in the textfield


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom validation

Posted by Igor Vaynberg <ig...@gmail.com>.
make both of your components not required, and use IFormValidator to
make sure at least one is filled in. alternatively you can override
form.onvalidate() and perform custom validation there. remember to use
component.getconvertedinput() and not getmodelobject() during
validation.

-igor


On Mon, Apr 6, 2009 at 7:26 PM, Chris Carlson <ch...@carlsoncentral.com> wrote:
> New to wicket trying to figure out the best way to do custom validation. I
> have a dropdown and a textfield, only 1 of which is required.  I want the
> user to select from the dropdown, and if their option is not listed, be
> able to enter anything in the textfield
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom validation

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
You might want to use ajax to show the textfield only after a specific
option in the dropdown is chosen.

Add, for example, OnChangeAjaxBehavior to the dropdown where you add
the textfield to the target. In the textfield's isVisible method you
evaluate whether to show it or not.

textfield = new textfield() {
  public boolean isVisible() {
     // should I show or should I not
  }
}
textfield.setOutputMarkupPlaceholderTag(true); // So that you can
update a hidden(not-shown) component

dropdown = new dropdown();
dropdown.add(new onchangeajaxbehavior() {
  onchange(target) {
    target.addComponent(textfield);
  }
});

**
Martin

2009/4/7 Chris Carlson <ch...@carlsoncentral.com>:
> New to wicket trying to figure out the best way to do custom validation. I
> have a dropdown and a textfield, only 1 of which is required.  I want the
> user to select from the dropdown, and if their option is not listed, be
> able to enter anything in the textfield
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org