You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mfs <fa...@gmail.com> on 2007/10/26 22:49:17 UTC

DropDownchoices : reflecting change

Hello Guys,

Well am sort of still playing around with wicket and getting hands-on
different components and their working...and so far its going pretty good,
this mail is just to get as much an understanding of the way a particular
task should be achieved in wicket and to make sure i am following the right
approach.

So i am using a dropdownchoice ("cityListDDC") with certain pre-filled
values in it, and wanted to see how the a change in values is to reflected
on a certain event (lets say onSelectionChanged event of another
dropdownchoice i.e. "state"), so my understanding was that in order to
re-populate/add values all i would need to do is change the model associated
with dropdown component (or in another words the model's subject...which in
this case is a List)  and it would render the new values as in the subject
the model wraps.

So i did a cityList.add("newCity") [cityList being the list associated with
the city DDC] onSelectionChanged event of the state DDC, and i see the new
city added in with the change in the model's subject, so far so good. But
than i tried to re-populate a totally new set of cities (on the same event)
using cityList.addAll(Collection) but than that didnt work, and in order to
achieve the same i had to do the following...

1) cityListDDC.setModel(null); // set the model to null
2) cityListDDC.setChoices(cityList); // new set of city choices 

now with that i had to achieve the same object involving the dropDown
component itself...and hence declare the cityDDC component as an instance
variable (initially i was just doing a new DDC and adding it to the
page-component without keeping a reference to it) so as to excess it from
another component/method...which i don't like and preferably would want to
keep the instance variables..atleast for the components...to the
minimum...so is that right approach, cant just changing the model would have
worked e.g. cityList.addAddAll(list) ? like in the earlier case, and if at
all i would need to declare my component as instance variables in order to
achieve the above task ? 

Thanks and Regards,

Farhan.
-- 
View this message in context: http://www.nabble.com/DropDownchoices-%3A-reflecting-change-tf4699703.html#a13435215
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