PDA

View Full Version : what is the best way to catch a combobox change?



TheBuzzer
25 Aug 2008, 10:31 AM
I am trying to use a combobox and to catch the change with a listener

however i would like to catch the final change where it is either selecting from the drop list or from typing and loosing focus on the box.

I realized the change will trigger if i type something and select a box and that will trigger 2 times.

But i want it to only catch change 1 time.

m0ntassar
26 Aug 2008, 12:35 AM
Would you please paste your listener code, I'm working on the same issue and I don't even know what could this listener look like :D

TheBuzzer
27 Aug 2008, 8:22 AM
this is what i did


Listener accountlookuplistener = new Listener<BaseEvent>() {

public void handleEvent(BaseEvent be) {
if (!eclipseaccountnumber.getRawValue().equals("")) {
try {
if (Integer.valueOf(eclipseaccountnumber.getRawValue()) != currenteclipsenumber) {
currenteclipsenumber = Integer.valueOf(eclipseaccountnumber.getRawValue());
Listener loadinformationlistiner = new Listener<ComponentEvent>() {

public void handleEvent(ComponentEvent ce) {
Dialog dialog = (Dialog) ce.component;
Button btn = dialog.getButtonPressed();
if (btn.getText().equals("Yes")) {
loadEclipseAccount(currenteclipsenumber);
}
}
};
MessageBox.confirm("Load Eclipse Information", "Do you want to load the eclipse information for account: " + eclipseaccountnumber.getRawValue() + "?", loadinformationlistiner);
}
} catch (Exception e) {
}
}
}
};

eclipseaccountnumber.addListener(Events.Collapse, accountlookuplistener);

mramadoss
15 Nov 2008, 3:13 PM
I have the same requirement. I'm using GXT 1.1.3.

Did you get your issue resolved. If yes, Can you please post a sample code?

Thanks

posta07
15 Nov 2008, 3:36 PM
I think you're listener is fine, but listen for the event, Events.Blur (instead of collapse... unless you do mean to listen for collapse events). The Blur event will fire when the combo loses focus.