On 7/3/08, Timo Rantalaiho <[EMAIL PROTECTED]> wrote:
> On Thu, 03 Jul 2008, Rakesh Sinha wrote:
>
> > Thanks for pointing this one out. Can you paste / point to a code
>  > fragement for - OnChangeAjaxBehavior and how to integrate with
>  > TextField.
>
>
> Use the source, Luke :) Just use it instead of the normal
>  AjaxFormComponentUpdatingBehavior.

Thanks Timo. Revised code looks something similar to this.

java:
====
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;

txtAge.add(new OnChangeAjaxBehavior() {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
                            ValidatorResult result =
ageValidator.validate(txtAge
                                                .getValue());
                lblModel.setErrorMessage(result.getMessage());
                target.addComponent(lblAgeValidate);
                }
        });



>
>
>  > >  Probably you can trim your code a bit but the basic idea
>  > >  is like that. Instead of passing the error message around
>  > >  you could make your Label use a pull model.
>  >
>  >   Can you clarify about the pull model here and how it gets supported
>  > with Wicket.
>
>
> By "pull model" I meant here just a Wicket IModel that reads
>  the necessary data in getObject, for example
>
>  lblAgeValidate = new Label("lblAgeValidate", new AbstractReadOnlyModel() {
>     @Override
>     public Object getObject() {
>         return txtAge.getValue();
>     }
>  }).setOutputMarkupId(true);

Thanks for the suggestion. That removes some boiler-plate code for sure.

>
>
>  Best wishes,
>  Timo
>
>  --
>  Timo Rantalaiho
>  Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>
>  ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to