Cascade ComboBox update using FormFieldFactory

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

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.

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():wink: {
UtilGlosasPaisDiv2 utilGlosasPaisDiv2 = it.next();
canton.addItem(utilGlosasPaisDiv2);
}

        }
    });