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 Mactaggart <st...@whitesquaresoft.com> on 2010/08/27 03:39:00 UTC

How to determine previous value in select after user change

Hi All,

I'm not sure if there is a wicket way to do this, or if I have to mange the
data myself, but we have a screen that has a select on it and need to detect
the user changing the value.
This is simply achieved with a AjaxFormComponentUpdatingBehavior, and works
well.

My problem is that by the time MY code gets executed, the component has
updated the model with the newly selected option, thus losing the existing
value.

I'm guessing AjaxFormComponentUpdatingBehavior won't have any way to track
this change, but is there any other behaviour I can use that allows me to
see the change in value?

I hope that makes sense, if not let me know and I'll post a simple example.

Cheers,
Steve

Re: How to determine previous value in select after user change

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Fri, Aug 27, 2010 at 8:18 PM, Steve Mactaggart <steve@whitesquaresoft.com
> wrote:

> That would work I guess, but I don't think it makes sense to build that
> logic into the dropdown, this is a function for the model, so I guess if
> there are no existing ways to do it i'll have to look at writing a
> "ChangeTrackedModel" or the like to wrap existing models in to manage the
> change.
>

Something like this might work for you: http://pastebin.com/katiSsGq

<http://pastebin.com/katiSsGq>That's just a quick-and-dirty approach - there
are likely optimizations that can be made to that code.


> What I really want to be able to do is in the ajax event determine if I
> want
> to allow the user to continue with the change, present them with a dialog
> or
> just cancel the change.
>

Seems like you may want a validator instead.


> And I wan to be able to just attach this logic to existing components
> without having to extend classes all over the shop.
>

Again, probably a validator, although the IModel solution is also reusable.

-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: How to determine previous value in select after user change

Posted by "vladimir.kovalyuk" <ko...@gmail.com>.
As a user I would be surprized if my selection in drop down caused dialog
opened. I would be surprized more if some values were not be possible to
select.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-determine-previous-value-in-select-after-user-change-tp2340548p2540001.html
Sent from the Users forum 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: How to determine previous value in select after user change

Posted by Steve Mactaggart <st...@whitesquaresoft.com>.
That would work I guess, but I don't think it makes sense to build that
logic into the dropdown, this is a function for the model, so I guess if
there are no existing ways to do it i'll have to look at writing a
"ChangeTrackedModel" or the like to wrap existing models in to manage the
change.

What I really want to be able to do is in the ajax event determine if I want
to allow the user to continue with the change, present them with a dialog or
just cancel the change.

And I wan to be able to just attach this logic to existing components
without having to extend classes all over the shop.

Is there anything like that around?  I've looked through wicketstuff, but
nothing jumped out at me.

Cheers,
Steve

On Fri, Aug 27, 2010 at 4:35 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> class mydropdown extends dropdown {
> private object last;
> protected void updatemodel() {
>   last=getmodelobject();
>  super.updatemodel();
> }
>
> -igor
>
> On Thu, Aug 26, 2010 at 6:39 PM, Steve Mactaggart
> <st...@whitesquaresoft.com> wrote:
> > Hi All,
> >
> > I'm not sure if there is a wicket way to do this, or if I have to mange
> the
> > data myself, but we have a screen that has a select on it and need to
> detect
> > the user changing the value.
> > This is simply achieved with a AjaxFormComponentUpdatingBehavior, and
> works
> > well.
> >
> > My problem is that by the time MY code gets executed, the component has
> > updated the model with the newly selected option, thus losing the
> existing
> > value.
> >
> > I'm guessing AjaxFormComponentUpdatingBehavior won't have any way to
> track
> > this change, but is there any other behaviour I can use that allows me to
> > see the change in value?
> >
> > I hope that makes sense, if not let me know and I'll post a simple
> example.
> >
> > Cheers,
> > Steve
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to determine previous value in select after user change

Posted by Igor Vaynberg <ig...@gmail.com>.
class mydropdown extends dropdown {
private object last;
protected void updatemodel() {
   last=getmodelobject();
  super.updatemodel();
}

-igor

On Thu, Aug 26, 2010 at 6:39 PM, Steve Mactaggart
<st...@whitesquaresoft.com> wrote:
> Hi All,
>
> I'm not sure if there is a wicket way to do this, or if I have to mange the
> data myself, but we have a screen that has a select on it and need to detect
> the user changing the value.
> This is simply achieved with a AjaxFormComponentUpdatingBehavior, and works
> well.
>
> My problem is that by the time MY code gets executed, the component has
> updated the model with the newly selected option, thus losing the existing
> value.
>
> I'm guessing AjaxFormComponentUpdatingBehavior won't have any way to track
> this change, but is there any other behaviour I can use that allows me to
> see the change in value?
>
> I hope that makes sense, if not let me know and I'll post a simple example.
>
> Cheers,
> Steve
>

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