Announcement

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

  • 6.1p: Unnecessary fetch for SelectItems in readOnly:true DynamicForm

    Hi Isomorphic,

    please see this BuiltInDS-based testcase (v11.1p_2018-12-04):

    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.AdvancedCriteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.ReadOnlyDisplayAppearance;
    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.fields.FormItem;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    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() {
            DataSource.get("employees").invalidateCache();
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("SelectItem showing outer border even if in read only mode" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final DynamicForm employeesForm = new DynamicForm();
    
            employeesForm.setHeight100();
            employeesForm.setAutoFetchData(false);
            employeesForm.setCanEdit(false);
            employeesForm.setReadOnlyDisplay(ReadOnlyDisplayAppearance.STATIC);
            employeesForm.setDataSource(DataSource.get("employees"));
    
            FormItem employeeId = new FormItem("EmployeeId");
            employeeId.setCanEdit(false);
    
            FormItem name = new FormItem("Name");
            name.setCanEdit(false);
    
            FormItem gender = new FormItem("Gender");
    
            SelectItem reportsTo = new SelectItem("ReportsTo");
            ListGrid props = new ListGrid();
            props.setDrawAllMaxCells(0);
            reportsTo.setPickListProperties(props);
            reportsTo.setOptionDataSource(DataSource.get("employees"));
    
            FormItem job = new FormItem("Job");
    
            employeesForm.setFields(employeeId, name, gender, reportsTo, job);
            employeesForm.fetchData(new AdvancedCriteria(new Criterion(employeeId.getName(), OperatorId.EQUALS, 192)));
            w.addItem(employeesForm);
            w.show();
        }
    }
    employees.ds.xml:
    Code:
    <DataSource 
        ID="employees"
        serverType="sql"
        tableName="employeeTable"
        recordName="employee"
        testFileName="/examples/shared/ds/test_data/employees.data.xml"
        titleField="Name"
    >
        <fields>
            <field name="userOrder"       title="userOrder"       type="integer"  canEdit="false"    hidden="true"/>
            <field name="Name"            title="Name"            type="text"     length="128"/>
            <field name="EmployeeId"      title="Employee ID"     type="integer"  primaryKey="true"  required="true"/>
            <field name="ReportsTo"       title="Manager"         type="integer"  required="true" 
                   foreignKey="employees.EmployeeId"  rootValue="1" detail="true" displayField="ReportsToName" />
            <field name="ReportsToName"   includeFrom="employees.Name"></field>
            <field name="Job"             title="Title"           type="text"     length="128"/> 
            <field name="Email"           title="Email"           type="text"     length="128"/>
            <field name="EmployeeType"    title="Employee Type"   type="text"     length="40"/>
            <field name="EmployeeStatus"  title="Status"          type="text"     length="40"/>
            <field name="Salary"          title="Salary"          type="float"/>
            <field name="OrgUnit"         title="Org Unit"        type="text"     length="128"/>
            <field name="Gender"          title="Gender"          type="text"     length="7">
                <valueMap>
                    <value>male</value>
                    <value>female</value>
                </valueMap>
            </field>
            <field name="MaritalStatus"   title="Marital Status"  type="text"     length="10">
                <valueMap>
                    <value>married</value>
                    <value>single</value>
                </valueMap>
            </field>
        </fields>
    </DataSource>
    As you can see in the Developer Console screenshot, the SelectItem also does a fetch for it's picklist, even if the form is not editable.

    Click image for larger version

Name:	Unnecessary fetch.png
Views:	1
Size:	21.2 KB
ID:	256115

    Best regards
    Blama

  • #2
    Hi Isomorphic,

    I just saw that this does not happen in 12.0p, where the pickList fetch is always (=even in read/write mode) done only after I open the pickList (=never in read-only mode), so this is non-issue for me.

    Best regards
    Blama

    Comment

    Working...
    X