Announcement

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

  • 6.1p: Severe problem with ValuesManager when a field has the same name as an optionDataSource field of a SelectItem

    Hi Isomorphic,

    please see this testcase (v11.1p_2018-01-11) where the field name already starts with the wrong data (data in RPC Tab is correct, NAME:"Reseller 1") and also changes after selecting an entry of the SelectItem.
    As I needed equal names, I did not use animals or supplyItem/employees, but own tables instead. DDL is included.

    IMHO the issue is that the name column of the company table (used for the SelectItem) somehow interferes with the name column of the reseller table (used for the DynamicForm).

    Click image for larger version

Name:	ValuesManager problem.gif
Views:	1
Size:	60.1 KB
ID:	251187

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.Criteria;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    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.ValuesManager;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("ValuesManager causes SelectItem selection to change TextItem as well." + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ValuesManager valuesManager = new ValuesManager();
            valuesManager.setDataSource(DataSource.get("RESELLER"));
    
            {
                final DynamicForm df = new DynamicForm();
                df.setIsGroup(true);
                df.setWidth(500);
                df.setTitleWidth(200);
                df.setAutoFetchData(false);
    
                TextItem nameTI = new TextItem("NAME");
                TextItem city = new TextItem("CITY");
                TextItem phone = new TextItem("TELEPHONE");
                SelectItem mcbiFlow = new SelectItem("COMPANY_ID");
                mcbiFlow.setDisplayField("NAME");
                mcbiFlow.setValueField("ID");
                df.setDataSource(valuesManager.getDataSource());
                df.setFields(nameTI, city, phone, mcbiFlow);
                valuesManager.addMember(df);
                w.addItem(df);
            }
            {
                final DynamicForm df2 = new DynamicForm();
                df2.setIsGroup(true);
                df2.setWidth(500);
                df2.setTitleWidth(200);
                df2.setAutoFetchData(false);
                TextItem cat1 = new TextItem("CAT1");
                TextItem cat2 = new TextItem("CAT2");
                df2.setDataSource(valuesManager.getDataSource());
                df2.setFields(cat1, cat2);
                valuesManager.addMember(df2);
                w.addItem(df2);
            }
            {
                IButton btn = new IButton("Save data");
                btn.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        valuesManager.saveData();
                    };
                });
                w.addItem(btn);
            }
    
            valuesManager.fetchData(new Criteria("ID", "1"));
            w.show();
        }
    }
    RESELLER.ds.xml (add in BuiltInDS.html):
    Code:
    <DataSource ID="RESELLER" serverType="sql" tableName="RESELLER">
        <fields>
            <field name="ID" type="integer" primaryKey="true" required="true" />
            <field foreignKey="COMPANY.ID" displayField="COMPANY_NAME" name="COMPANY_ID" type="integer" />
            <field name="COMPANY_NAME" includeFrom="COMPANY.NAME" />
            <field name="NAME" type="text" />
            <field name="CITY" type="text" />
            <field name="TELEPHONE" type="text" />
            <field name="CAT1" type="text" />
            <field name="CAT2" type="text" />
        </fields>
    </DataSource>
    COMPANY.ds.xml (add in BuiltInDS.html):
    Code:
    <DataSource ID="COMPANY" serverType="sql" tableName="COMPANY">
        <fields>
            <field name="ID" type="integer" primaryKey="true" required="true" />
            <field name="NAME" type="text" />
            <field name="CITY" type="text" />
            <field name="TELEPHONE" type="text" />
        </fields>
    </DataSource>
    DDL (Oracle, but any should do):
    Code:
    DROP TABLE reseller;
    DROP TABLE company;
    
    CREATE TABLE company (
        id          INTEGER NOT NULL,
        name        VARCHAR2(20),
        city        VARCHAR2(20),
        telephone   VARCHAR2(20),
        CONSTRAINT company_pk PRIMARY KEY ( id ) ENABLE
    );
    
    CREATE TABLE reseller (
        id           INTEGER NOT NULL,
        company_id   INTEGER,
        name         VARCHAR2(20),
        city         VARCHAR2(20),
        telephone    VARCHAR2(20),
        cat1         VARCHAR2(20),
        cat2         VARCHAR2(20),
        CONSTRAINT reseller_pk PRIMARY KEY ( id ),
        CONSTRAINT reseller_fk1 FOREIGN KEY ( company_id )
            REFERENCES company ( id )
        ENABLE
    );
    
    INSERT INTO company (ID,NAME,city,telephone) VALUES (1,'Company 1','NY','012345');
    INSERT INTO company (ID,NAME,city,telephone) VALUES (2,'Company 2','NJ','65431');
    INSERT INTO reseller (ID,company_id,NAME,city,telephone,cat1,cat2) VALUES (1,1,'Reseller 1','SF','987654','ABC','DEF');
    COMMIT;
    This is happening in my application as well.

    Best regards
    Blama
Working...
X