Hi

Introduction to problem:
I have several registers that can be downloaded separately from server
asynchronically (using standard Callback mechanism).
When particular register is downloaded it invokes notifyObservers
method (using Observer pattern) that updates its observers..
I have combobox, that shows one of the register's entries.
This combobox has listener, that do something when user selects item
from dropdown list.
Combobox is added to one window, it is not set as "lazy reneder".

And now:

1st situation:
When downloading registers is invoked only when needed - actually when
window (with given combobox) is shown, then everything works ok.
Combobox is filled with register elements and when I select item then
ComboboxListener invokes and does his job. This is the correct case.

2nd situation:
I want to start downloading registers when application starts.
Registers are downloaded, observers were invoked. When I want to show
window with given combobox, combobox has his register elements (OK)
but when I select some element, no action is taken - It looks like
combobox doesn't have listeners.

I notice this mechanism works OK only when register is downloaded
after combobox is shown (maybe: rendered(?)). But when register is
downloaded before combobox was shown, listeners disappear from
combobox.

Source code is very simple and I think it is even not needed here but
I will put important lines here:


Panel with combobox:

...
this.codeCostsComboBox = new ComboBox();
this.codeCostsComboBox.setStore( this.productCostsStore );
this.codeCostsComboBox.setLabel( "Product" );
this.codeCostsComboBox.setValueField( productCodeFieldName );
this.codeCostsComboBox.setDisplayField( productNameFieldName );
this.codeCostsComboBox.setWidth( MainForm.productComboBoxDefaultWidth );
this.codeCostsComboBox.setListWidth( MainForm.productComboBoxDefaultWidth
+ 50 );
this.codeCostsComboBox.setEmptyText( "Select product" );
...
// MessageBox.alert( "Adding listeneres" );
this.codeCostsComboBox.addListener( new DefaultUnitSelector() );
this.codeCostsComboBox.addListener( new DefaultPriceSetter() );
...
comboBoxObserver = new Observer() {
        public void update( Observable o , Object arg ) {
                if( arg != null ) {
                        final List codesNames = (List)arg;
                        productCostsStore.removeAll();
                        final Iterator codesNamesIt = codesNames.iterator();
                        while( codesNamesIt.hasNext() ) {
                                final Registerable rse = 
(Registerable)codesNamesIt.next();
                                productCostsStore.add( 
productInfoRecordDef.createRecord( new
Object[] {
                                        rse.getCode() , rse.getName() , rse
                                } ) );
                        }
                        productCostsStore.commitChanges();
                        codeCostsComboBox.clearValue();
                        codeCostsComboBox.setDisabled( false );
                }
        }
};


DefaultUnitSelector class:

public class DefaultUnitSelector extends ComboBoxListenerAdapter {
        public void onSelect( ComboBox comboBox , Record record , int index )
{
                MessageBox.alert( "Invoked" );
}


DefaultPriceSetter class:

public class DefaultPriceSetter extends ComboBoxListenerAdapter {
        public void onSelect( ComboBox comboBox , Record record , int index )
{
                MessageBox.alert( "Invoked" );
}


Observer pattern is obvious.

Is it some bug or proper behaviour?
Best Regards
Radek Adamiak

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"GWT-Ext Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/gwt-ext?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to