Announcement

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

    Development Mode problem with ListGridFieldType.IMAGE in SmartGWT 2.1 TreeGrid.

    The design for part of our UI calls for a menu button to the left of each row in an editable TreeGrid. We have achieved this by adding a field with type set to ListGridFieldType.IMAGE after the name field and then re-ordering the fields in a DrawHandler. Is this a sensible approach?

    Since upgrading to SmartGWT 2.1, when we are in Development Mode, clicks on one of the Menu buttons result in the image being replaced with the text “menu” and the following appearing in the browser’s tab in the GWT Development Mode window:

    Code:
    00:00:22.629 [ERROR] 14:49:41.161:TMR8:WARN:DynamicForm:isc_DynamicForm_0:focusInItem: item cannot accept focus: [StaticTextItem ID:isc_StaticTextItem_0 name:Menu] 
    com.smartgwt.client.core.JsObject$SGWT_WARN: 14:49:41.161:TMR8:WARN:DynamicForm:isc_DynamicForm_0:focusInItem: item cannot accept focus: [StaticTextItem ID:isc_StaticTextItem_0 name:Menu]
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
    	at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    	at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
    	at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
    	at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
    	at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
    	at java.lang.Thread.run(Thread.java:619)
    We don't see the icon getting replaced with text when the code is compiled, but would like to eliminate the above warning, so that we don't accidentally miss more significant problems. Do you have any suggestions?

    This example draws heavily on the Tree Editing sample in the Showcase and reproduces the problem described when you click on one of the Menu icons:

    Code:
    package com.mycompany.myapp.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.mycompany.myapp.client.data.EmployeeXmlDS;
    import com.smartgwt.client.types.Alignment;
    import com.smartgwt.client.types.ListGridEditEvent;
    import com.smartgwt.client.types.ListGridFieldType;
    import com.smartgwt.client.widgets.events.DrawEvent;
    import com.smartgwt.client.widgets.events.DrawHandler;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.tree.TreeGrid;
    import com.smartgwt.client.widgets.tree.TreeGridField;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class HelloWorld implements EntryPoint {
    
    	/**
    	 * This is the entry point method.
    	 */
    	public void onModuleLoad() {
    
    		TreeGridField fieldName = new TreeGridField("Name", 150);  
            TreeGridField fieldJob = new TreeGridField("Job", 150);  
            TreeGridField fieldSalary = new TreeGridField("Salary");  
            
            TreeGridField fieldMenu = new TreeGridField("Menu", 35);
    
            fieldMenu.setImageURLPrefix("../../public/img/icn-");
            fieldMenu.setType(ListGridFieldType.IMAGE);
            fieldMenu.setImageURLSuffix(".gif");
            fieldMenu.setImageWidth(23);
            fieldMenu.setImageHeight(21);
            fieldMenu.setCanEdit(false);
            fieldMenu.setCanSort(false);
            fieldMenu.setAlign(Alignment.CENTER);
      
            final TreeGrid employeeTree = new TreeGrid();  
            employeeTree.setWidth(500);  
            employeeTree.setHeight(250);  
            employeeTree.setDataSource(EmployeeXmlDS.getInstance());  
            employeeTree.setNodeIcon("icons/16/person.png");  
            employeeTree.setFolderIcon("icons/16/person.png");  
            employeeTree.setAutoFetchData(true);  
            employeeTree.setLoadDataOnDemand(false);  
            employeeTree.setCanEdit(true);  
            employeeTree.setCanReorderRecords(true);  
            employeeTree.setCanAcceptDroppedRecords(true);  
            employeeTree.setShowDropIcons(false);  
            employeeTree.setShowOpenIcons(false);  
            employeeTree.setClosedIconSuffix("");  
            employeeTree.setFields(fieldName, fieldMenu, fieldJob, fieldSalary);
            employeeTree.setEditByCell(true);
            employeeTree.setEditEvent(ListGridEditEvent.CLICK);
              
            employeeTree.addDrawHandler(new DrawHandler() {
    
    			@Override
    			public void onDraw(DrawEvent event) {
    				employeeTree.reorderField(1, 0);
    				
    			}
            	
            });
            
                     
            VLayout mainView = new VLayout(10);  
            mainView.setHeight100();  
            mainView.setWidth100();  
      
            mainView.addMember(employeeTree);  
    	
    		RootPanel.get().add(mainView);
    	}
    
    }
    I also added a DataSourceTextField to the EmployeeXmlDS:

    Code:
    package com.mycompany.myapp.client.data;
    
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.fields.DataSourceFloatField;
    import com.smartgwt.client.data.fields.DataSourceIntegerField;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    
    public class EmployeeXmlDS extends DataSource {
    
    	private static EmployeeXmlDS instance = null;  
    	  
        public static EmployeeXmlDS getInstance() {  
            if (instance == null) {  
                instance = new EmployeeXmlDS("employeesDS");  
            }  
            return instance;  
        }  
      
        public EmployeeXmlDS(String id) {  
      
            setID(id);  
            setTitleField("Name");  
            setRecordXPath("/List/employee");  
            DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);  
      
            DataSourceIntegerField employeeIdField = new DataSourceIntegerField("EmployeeId", "Employee ID");  
            employeeIdField.setPrimaryKey(true);  
            employeeIdField.setRequired(true);  
      
            DataSourceIntegerField reportsToField = new DataSourceIntegerField("ReportsTo", "Manager");  
            reportsToField.setRequired(true);  
            reportsToField.setForeignKey(id + ".EmployeeId");  
            reportsToField.setRootValue("1");  
      
            DataSourceTextField menuField = new DataSourceTextField("Menu", "Menu", 5);
            
            DataSourceTextField jobField = new DataSourceTextField("Job", "Title", 128);  
            DataSourceTextField emailField = new DataSourceTextField("Email", "Email", 128);  
            DataSourceTextField statusField = new DataSourceTextField("EmployeeStatus", "Status", 40);  
            DataSourceFloatField salaryField = new DataSourceFloatField("Salary", "Salary");  
            DataSourceTextField orgField = new DataSourceTextField("OrgUnit", "Org Unit", 128);  
            DataSourceTextField genderField = new DataSourceTextField("Gender", "Gender", 7);  
            genderField.setValueMap("male", "female");  
            DataSourceTextField maritalStatusField = new DataSourceTextField("MaritalStatus", "Marital Status", 10);  
      
            setFields(nameField, employeeIdField, menuField, reportsToField, jobField, emailField,  
                    statusField, salaryField, orgField, genderField, maritalStatusField);  
      
            setDataURL("ds/test_data/employees.data.xml");  
            setClientOnly(true);  
        }  
    }
    Adding <Menu>menu</Menu> to the first few employee records in war/ds/test_data/employees.data.xml is enough to demonstrate the problem.

    The attached icon was placed in war/public/img/icn-menu.gif.
    Attached Files

    #2
    Are you able to try out a nightly to see if this problem is already resolved? We are very close to releasing 2.2, which you should probably ship on.

    Comment


      #3
      This does seem to have been resolved in build 1161. However, I have noticed other problems with that build, which I have described here: http://forums.smartclient.com/showthread.php?t=11039

      Comment

      Working...
      X