Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    "Loading" message after transport error in comboBoxItem fetchMissingValues

    Hi,
    This is a scenario taken from application usage on mobile device:

    There is a grid and related form displayed. When user selects a record, then this record is shown on the related form via df.editRecord().
    Related form has ComboBoxItems with foreign keys and optionDataSources.

    Now, when mobile browser has lost connection and user selects a record already shown in the grid, then fetchMissingValues mechanism kicks in ComboBoxItems and TRANSPORT_ERROR is handled by default. After that, all ComboBoxItems has "Loading..." shown as displayed value.

    The problem is that even though connection is restored and user even select another record from grid, ComboBoxItems on form still show "Loading...".

    To simulate it here is an simple example using non existing fake_option.xml to feed ComboBoxItem.
    Press "Set" button to set value and trigger a fetch causing transport error.
    Under "Clear" button I tried some ways to clear "Loading" message and restore usual ComboBoxItem functionality with no luck.
    Click image for larger version

Name:	fetchMissingValues.gif
Views:	100
Size:	572.8 KB
ID:	269204
    Code:
    package pl.com.tech4.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DataSourceField;
    import com.smartgwt.client.data.OperationBinding;
    import com.smartgwt.client.data.RestDataSource;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    import com.smartgwt.client.types.DSDataFormat;
    import com.smartgwt.client.types.DSOperationType;
    import com.smartgwt.client.types.DSProtocol;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class MainEntryPoint implements EntryPoint {
    
        public void onModuleLoad() {
    
            layout();
        }
    
        private void layout() {
    
            RestDataSource ds = new RestDataSource();
            ds.setID("DS");
    
            OperationBinding fetchBinding = new OperationBinding();
            fetchBinding.setOperationType(DSOperationType.FETCH);
            fetchBinding.setDataFormat(DSDataFormat.XML);
            fetchBinding.setDataProtocol(DSProtocol.POSTXML);
    
            ds.setOperationBindings(fetchBinding);
            ds.setDataURL("select.xml");
    
            DataSourceField fieldId = new DataSourceField();
            fieldId.setName("id");
            fieldId.setPrimaryKey(true);
            fieldId.setHidden(true);
    
            DataSourceField fieldOption = new DataSourceField();
            fieldOption.setName("option");
            fieldOption.setForeignKey("optionDS.id");
            ComboBoxItem itemOption = new ComboBoxItem("option");
            itemOption.setValueField("id");
            itemOption.setDisplayField("name");
            fieldOption.setEditorType(itemOption);
    
            ds.setFields(fieldId, fieldOption);
    
            RestDataSource optionDs = new RestDataSource();
            optionDs.setID("optionDS");
            optionDs.setOperationBindings(fetchBinding);
            optionDs.setDataURL("fake_option.xml");
    
            DataSourceField optionFieldId = new DataSourceField();
            optionFieldId.setName("id");
            optionFieldId.setPrimaryKey(true);
    
            DataSourceTextField optionFieldName = new DataSourceTextField();
            optionFieldName.setName("name");
    
            optionDs.setFields(optionFieldId, optionFieldName);
    
            final DynamicForm df = new DynamicForm();
            df.setDataSource(ds);
    
            IButton setValueButton = new IButton("Set");
            setValueButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    df.setValue("option", "1");
                }
            });
            IButton clearValueButton = new IButton("Clear");
            clearValueButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    df.clearValue("option");
                    df.resetValues();
                }
            });
    
            VLayout layout = new VLayout();
            layout.addMember(df);
            layout.addMember(setValueButton);
            layout.addMember(clearValueButton);
    
            layout.draw();
        }
    
    }
    What would be a proper way of dealing with such situation?
    Thanks,
    MichalG

    #2
    Thanks for the notification and the clear test case.
    We see the problem and have a developer taking a look

    Regards
    Isomorphic Software

    Comment

    Working...
    X