Rene
(Rene Aravena)
August 22, 2010, 8:50pm
1
Hello,
It is possible to update a ComboBox depending on another ComboBoxt
using FormFieldFactory
?, for example this relation: ComboBox cb1 show countries and ComboBox cb2 show cities, when you change country in cb1, cb2 must show the cities of that country, some sample code?
Thanks
Lawal
(Lawal Olufowobi)
August 23, 2010, 6:50am
2
No sample code.
But here is what you can do!
What you can do is to add a listener to the combobox which would update the second one.
say
psuedocode :
when value changes on the cb1
get the value
set it to the value in cb2
Can’t be simpler.
Rene
(Rene Aravena)
August 23, 2010, 3:07pm
3
is solved
ComboBox provincia ------------> (1…* ) in ComboBox canton
sample:
List<UtilGlosasPaisDiv1> lProvincia = utilGlosasPaisDiv1Facade.findAll();
for (Iterator<UtilGlosasPaisDiv1> it = lProvincia.iterator(); it.hasNext();) {
UtilGlosasPaisDiv1 o = it.next();
provincia.addItem(o);
}
provincia.setImmediate(true);
provincia.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
UtilGlosasPaisDiv1 ps = (UtilGlosasPaisDiv1) provincia.getValue();
List<UtilGlosasPaisDiv2> cs = new ArrayList<UtilGlosasPaisDiv2>(ps.getUtilGlosasPaisDiv2Collection());
canton.removeAllItems();
//load new items
for (Iterator it = cs.iterator(); it.hasNext() {
UtilGlosasPaisDiv2 utilGlosasPaisDiv2 = it.next();
canton.addItem(utilGlosasPaisDiv2);
}
}
});