PDA

View Full Version : Advanced combobox binding problem



Lada
10 Jan 2011, 7:47 AM
Hi all!
I have a problem with a combobox case mutated from the Advanced Combobx Example. What I want to do is to help the user to fill some form fields after a selection has been made on the combobox. Start writing on Country field triggers the combobox and when a selection has been made, the other fields are populated through a service call. Everything goes right and the binding works well (press the button to see the bean values). But if a user speedy fills the country field without triggering the combobox, the binding reports null as country value. I know that if the combobox doesn't trigger may be binding cannot be done, but there is a solution for this problem?

TIA!

Ersmarker
28 Jan 2011, 1:12 AM
Hi.

Since you load the store asynchronously, the store will be empty if you type in a country faster than the RPC call as loaded the store. Then the binding will fail. If you need the "fast" behaviour, you need to preload the store.
Also set cbCountry.setLazyRender(false);

Lada
1 Feb 2011, 5:23 AM
Hi!
Of course preloading can be done only with a small set of data. If the search is made against a very big table there aren't other solutions?

Thanks!

Ersmarker
1 Feb 2011, 5:29 AM
Hi.

Without the store loaded there is no way the binding can work.
But you can try this workaround:
You can listen to the blur event on the country field and get the value by .getRawValue(); Then trigger the service that the country data.

Lada
3 Feb 2011, 8:40 AM
Hi!
I have already tried this solution but it doesn'work because there are some side effects. Blur event triggers also after the advanced combobox has started regularly so there is an overlapping effect. I believe that disabling the trigger of blur event in this case may works but I don't if it is possible.

Thanks!

Ersmarker
4 Feb 2011, 12:02 AM
Hi.

You can check in the blur event if the value has been set properly. I that case you don't need to do anything.



cbCountry.addListener(Events.Blur, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent fe) {
if (cbCountry.getValue() != null)
if (cbCountry.getRawValue().equals(cbCountry.getValue().getCountry())) return;
// Do Service
}
});

Lada
14 Feb 2011, 5:11 AM
Thanks, it works! =D>