You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by karthik Guru <be...@gmail.com> on 2007/10/23 08:16:11 UTC

Refreshing components with new data w/o altering the backing model

I have a form like this -

Name:  [.....]
Zip:      [.....]
City:     [.....]
State:   [.....]

[Save]

On filling the zip i want to auto populate the city and state. I can attach
a AjaxFormComponentUpdatingBehavior to the zip field and do this. But I
don't want to update the zip model, so i plan to have my version of
AjaxFormComponentUpdatingBehavior and 'not' update the model. I can possibly
get the user entered value from the convertedInput.

But I don't want to want to update the city and the state model either to
auto-populate the fields.

Basically I want to hold off on the model updates until somebody clicks the
save button.

Can i set the converted input on a component and get it to refresh through
Ajax?
I know that I can do this through javascript ($(fieldId).value = ''blah
blah')and add it to AjaxTarget. But i was wondering if i can just work with
components (do setConvertedInput / something) and then add it to Ajaxtarget
and make it work?

-- karthik --

Re: Refreshing components with new data w/o altering the backing model

Posted by Oliver Lieven <ol...@provantis.de>.
Hi,

two week ago I had a similar problem (see Thread
"AutoCompleteTextfield---how to populate two input fields -
tf4592192.html#a13166291")

The solution was to have an autocomplete-list attached to the zipcode and
the city-field. The list shows the valid zipcode-city combinations for the
zipcode/city entered so far. When the user chooses an entry from the list,
both fields are filled accordingly.

To achieve this the AutoCompleteTextField's behavior was modified so that it
is able to update two fields at once from the user's selection (with
different values). In that way, entering the data occurs in the browser
only, the model remains untouched until the user submits the form. (Indeed,
a slightly different approach, but works great).

regards,
Oliver



Matej Knopp-2 wrote:
> 
> I think what you could try (though it would be a nasty hack :) ) is to
> set rawInput property on FormComponent. However, you'll need some
> introspection to do that, as it is private and we don't plan to
> provide an accessor for it :)
> 
> -Matej
> 
> On 10/23/07, karthik Guru <be...@gmail.com> wrote:
>> I have a form like this -
>>
>> Name:  [.....]
>> Zip:      [.....]
>> City:     [.....]
>> State:   [.....]
>>
>> [Save]
>>
>> On filling the zip i want to auto populate the city and state. I can
>> attach
>> a AjaxFormComponentUpdatingBehavior to the zip field and do this. But I
>> don't want to update the zip model, so i plan to have my version of
>> AjaxFormComponentUpdatingBehavior and 'not' update the model. I can
>> possibly
>> get the user entered value from the convertedInput.
>>
>> But I don't want to want to update the city and the state model either to
>> auto-populate the fields.
>>
>> Basically I want to hold off on the model updates until somebody clicks
>> the
>> save button.
>>
>> Can i set the converted input on a component and get it to refresh
>> through
>> Ajax?
>> I know that I can do this through javascript ($(fieldId).value = ''blah
>> blah')and add it to AjaxTarget. But i was wondering if i can just work
>> with
>> components (do setConvertedInput / something) and then add it to
>> Ajaxtarget
>> and make it work?
>>
>> -- karthik --
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Refreshing-components-with-new-data-w-o-altering-the-backing-model-tf4675439.html#a13359783
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Refreshing components with new data w/o altering the backing model

Posted by Igor Vaynberg <ig...@gmail.com>.
i dont think this case warrants "repainting" the form component via
ajax when all you really have to do is write simple js that puts the
selected text into the textfield. that said, there are  many ways to
skin the cat...

-igor

On 10/24/07, Swaroop Belur <sw...@gmail.com> wrote:
> Igor,
>
> Regarding the stated problem:
>
> As we know ,the formcomponent's getValue method returns value from the model
> for the component when rendering if raw input is equal to no raw input
> constant. So basically the problem is that component's model should
> not be updated until the user submits the form containing the zip field
> here.
> So  looks like holding on to the raw input until the form is actually
> submitted
> should do the trick. Do you think its a good idea to hold on to the raw
> input
> by not calling clearInput in ajaxformcomponentupdatingbehavior.
> It may be cleared in process() call of form if valid.
>
> The only problem seems to be distinguishing incorrect input
> from correct input. May be in this case, it will be upto user
> to render any error label or feedback in that case.
>
> I understand this may go against fundamental way wicket works..
> i.e to pull only from models if data is correct. But the scenario
> described above means that user doesnt want to update any transient
> data (- as user may keep changing zip field many times for example) ,
> in models - so therefore pick up from component instead of model
> when rendering EXCEPT after submit when rendering the same page
> again.
>
> -swaroop
>
>
>
>
> On 10/23/07, Igor Vaynberg <ig...@gmail.com> wrote:
> >
> > dont know if you need that, just add javascript to the ajax target to
> > set the values on the fields..
> >
> > -igor
> >
> >
> > On 10/23/07, Matej Knopp <ma...@gmail.com> wrote:
> > > I think what you could try (though it would be a nasty hack :) ) is to
> > > set rawInput property on FormComponent. However, you'll need some
> > > introspection to do that, as it is private and we don't plan to
> > > provide an accessor for it :)
> > >
> > > -Matej
> > >
> > > On 10/23/07, karthik Guru <be...@gmail.com> wrote:
> > > > I have a form like this -
> > > >
> > > > Name:  [.....]
> > > > Zip:      [.....]
> > > > City:     [.....]
> > > > State:   [.....]
> > > >
> > > > [Save]
> > > >
> > > > On filling the zip i want to auto populate the city and state. I can
> > attach
> > > > a AjaxFormComponentUpdatingBehavior to the zip field and do this. But
> > I
> > > > don't want to update the zip model, so i plan to have my version of
> > > > AjaxFormComponentUpdatingBehavior and 'not' update the model. I can
> > possibly
> > > > get the user entered value from the convertedInput.
> > > >
> > > > But I don't want to want to update the city and the state model either
> > to
> > > > auto-populate the fields.
> > > >
> > > > Basically I want to hold off on the model updates until somebody
> > clicks the
> > > > save button.
> > > >
> > > > Can i set the converted input on a component and get it to refresh
> > through
> > > > Ajax?
> > > > I know that I can do this through javascript ($(fieldId).value =
> > ''blah
> > > > blah')and add it to AjaxTarget. But i was wondering if i can just work
> > with
> > > > components (do setConvertedInput / something) and then add it to
> > Ajaxtarget
> > > > and make it work?
> > > >
> > > > -- karthik --
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>

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


Re: Refreshing components with new data w/o altering the backing model

Posted by Swaroop Belur <sw...@gmail.com>.
Igor,

Regarding the stated problem:

As we know ,the formcomponent's getValue method returns value from the model
for the component when rendering if raw input is equal to no raw input
constant. So basically the problem is that component's model should
not be updated until the user submits the form containing the zip field
here.
So  looks like holding on to the raw input until the form is actually
submitted
should do the trick. Do you think its a good idea to hold on to the raw
input
by not calling clearInput in ajaxformcomponentupdatingbehavior.
It may be cleared in process() call of form if valid.

The only problem seems to be distinguishing incorrect input
from correct input. May be in this case, it will be upto user
to render any error label or feedback in that case.

I understand this may go against fundamental way wicket works..
i.e to pull only from models if data is correct. But the scenario
described above means that user doesnt want to update any transient
data (- as user may keep changing zip field many times for example) ,
in models - so therefore pick up from component instead of model
when rendering EXCEPT after submit when rendering the same page
again.

-swaroop




On 10/23/07, Igor Vaynberg <ig...@gmail.com> wrote:
>
> dont know if you need that, just add javascript to the ajax target to
> set the values on the fields..
>
> -igor
>
>
> On 10/23/07, Matej Knopp <ma...@gmail.com> wrote:
> > I think what you could try (though it would be a nasty hack :) ) is to
> > set rawInput property on FormComponent. However, you'll need some
> > introspection to do that, as it is private and we don't plan to
> > provide an accessor for it :)
> >
> > -Matej
> >
> > On 10/23/07, karthik Guru <be...@gmail.com> wrote:
> > > I have a form like this -
> > >
> > > Name:  [.....]
> > > Zip:      [.....]
> > > City:     [.....]
> > > State:   [.....]
> > >
> > > [Save]
> > >
> > > On filling the zip i want to auto populate the city and state. I can
> attach
> > > a AjaxFormComponentUpdatingBehavior to the zip field and do this. But
> I
> > > don't want to update the zip model, so i plan to have my version of
> > > AjaxFormComponentUpdatingBehavior and 'not' update the model. I can
> possibly
> > > get the user entered value from the convertedInput.
> > >
> > > But I don't want to want to update the city and the state model either
> to
> > > auto-populate the fields.
> > >
> > > Basically I want to hold off on the model updates until somebody
> clicks the
> > > save button.
> > >
> > > Can i set the converted input on a component and get it to refresh
> through
> > > Ajax?
> > > I know that I can do this through javascript ($(fieldId).value =
> ''blah
> > > blah')and add it to AjaxTarget. But i was wondering if i can just work
> with
> > > components (do setConvertedInput / something) and then add it to
> Ajaxtarget
> > > and make it work?
> > >
> > > -- karthik --
> > >
> >
> > ---------------------------------------------------------------------
> > 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: Refreshing components with new data w/o altering the backing model

Posted by Igor Vaynberg <ig...@gmail.com>.
dont know if you need that, just add javascript to the ajax target to
set the values on the fields..

-igor


On 10/23/07, Matej Knopp <ma...@gmail.com> wrote:
> I think what you could try (though it would be a nasty hack :) ) is to
> set rawInput property on FormComponent. However, you'll need some
> introspection to do that, as it is private and we don't plan to
> provide an accessor for it :)
>
> -Matej
>
> On 10/23/07, karthik Guru <be...@gmail.com> wrote:
> > I have a form like this -
> >
> > Name:  [.....]
> > Zip:      [.....]
> > City:     [.....]
> > State:   [.....]
> >
> > [Save]
> >
> > On filling the zip i want to auto populate the city and state. I can attach
> > a AjaxFormComponentUpdatingBehavior to the zip field and do this. But I
> > don't want to update the zip model, so i plan to have my version of
> > AjaxFormComponentUpdatingBehavior and 'not' update the model. I can possibly
> > get the user entered value from the convertedInput.
> >
> > But I don't want to want to update the city and the state model either to
> > auto-populate the fields.
> >
> > Basically I want to hold off on the model updates until somebody clicks the
> > save button.
> >
> > Can i set the converted input on a component and get it to refresh through
> > Ajax?
> > I know that I can do this through javascript ($(fieldId).value = ''blah
> > blah')and add it to AjaxTarget. But i was wondering if i can just work with
> > components (do setConvertedInput / something) and then add it to Ajaxtarget
> > and make it work?
> >
> > -- karthik --
> >
>
> ---------------------------------------------------------------------
> 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: Refreshing components with new data w/o altering the backing model

Posted by Matej Knopp <ma...@gmail.com>.
I think what you could try (though it would be a nasty hack :) ) is to
set rawInput property on FormComponent. However, you'll need some
introspection to do that, as it is private and we don't plan to
provide an accessor for it :)

-Matej

On 10/23/07, karthik Guru <be...@gmail.com> wrote:
> I have a form like this -
>
> Name:  [.....]
> Zip:      [.....]
> City:     [.....]
> State:   [.....]
>
> [Save]
>
> On filling the zip i want to auto populate the city and state. I can attach
> a AjaxFormComponentUpdatingBehavior to the zip field and do this. But I
> don't want to update the zip model, so i plan to have my version of
> AjaxFormComponentUpdatingBehavior and 'not' update the model. I can possibly
> get the user entered value from the convertedInput.
>
> But I don't want to want to update the city and the state model either to
> auto-populate the fields.
>
> Basically I want to hold off on the model updates until somebody clicks the
> save button.
>
> Can i set the converted input on a component and get it to refresh through
> Ajax?
> I know that I can do this through javascript ($(fieldId).value = ''blah
> blah')and add it to AjaxTarget. But i was wondering if i can just work with
> components (do setConvertedInput / something) and then add it to Ajaxtarget
> and make it work?
>
> -- karthik --
>

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