You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steve Lowery <sl...@gatessolutions.com> on 2009/08/06 00:07:46 UTC

AjaxBehavior and onblur

I have a Form on my page that has amongst others 3 fields:  zipcode,
city, and state.  I would like it when the user enters data in the
zipcode field, an ajax request be generated to lookup and populate the
city and state fields in the form.  However, I don't want the underlying
model (an employee) to be updated until the form is submitted.  The
textfields' models are PropertyModels of the underlying Employee model.
AjaxFormComponentUpdatingBehavior("onblur") updates the model, but
persists the changes to the Employee object since it is a managed object
(we are using hibernate).  If I use an AjaxEventBehavior("onblur"), the
model doesn't get updated, but the getInput() and getValue() on the
zipcode textfield doesn't reflect what the user just entered.  It still
has what was in the original model.  Is there some way to have an ajax
call for an onblur (or whatever event) not update the model, but give
the handling code access to what data is currently in the component the
behavior is attached to?

 

Thanks, Steve


Re: AjaxBehavior and onblur

Posted by Igor Vaynberg <ig...@gmail.com>.
the simplest way is to use javascript to set the values on the textfields

-igor

On Wed, Aug 5, 2009 at 3:07 PM, Steve Lowery<sl...@gatessolutions.com> wrote:
> I have a Form on my page that has amongst others 3 fields:  zipcode,
> city, and state.  I would like it when the user enters data in the
> zipcode field, an ajax request be generated to lookup and populate the
> city and state fields in the form.  However, I don't want the underlying
> model (an employee) to be updated until the form is submitted.  The
> textfields' models are PropertyModels of the underlying Employee model.
> AjaxFormComponentUpdatingBehavior("onblur") updates the model, but
> persists the changes to the Employee object since it is a managed object
> (we are using hibernate).  If I use an AjaxEventBehavior("onblur"), the
> model doesn't get updated, but the getInput() and getValue() on the
> zipcode textfield doesn't reflect what the user just entered.  It still
> has what was in the original model.  Is there some way to have an ajax
> call for an onblur (or whatever event) not update the model, but give
> the handling code access to what data is currently in the component the
> behavior is attached to?
>
>
>
> Thanks, Steve
>
>

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