Announcement

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

    DataPath and Test datasource

    Hi,

    SC_SNAPSHOT-2011-03-24/EVAL Deployment
    FireFox 3.6.16

    I wanted to reproduce an error that we are having in our real app.
    However, I don't seem to be able to use a test datasource, datapath and a listgrid together.
    This is blocking me setting up the real repo case.

    In my standalone test case you will see a grid and a form.
    In the form the value of the boolean is correctly set (interpreted), but in the grid it is not?
    Moreover, if you try to edit the boolean in the grid you get a nullpointer.

    Keep in mind, I'm not seeing this behavior in our real app (there it all works fine on both grid and form, both using dataPath).
    So, I'm guessing it has something to do with the test datasource?!?

    Regards,
    Bart

    Code:
    Uncaught JavaScript exception [_2 is null] in http://127.0.0.1:8888/standalone/sc/modules/ISC_Core.js, line 3387
    Code:
    public class Standalone implements EntryPoint {
    		
    	private static Canvas masterPanel = null;
    	
    	boolean pickerShowing = false;
    	
    	public void onModuleLoad() {
    		 
    		 devConsole = new Button("DEV Console");
    		 devConsole.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
    
    				public void onClick(ClickEvent event) {
    						SC.showConsole();
    				}
    		});	 
    	  		
    		//masterPanel should be a Layout
    		masterPanel = new Canvas(); 
    		masterPanel.setHeight100();
    		masterPanel.setWidth100();
    		masterPanel.setStyleName("pageBackground"); //background style from skin
    		
    		masterPanel.addChild(testCase11());
    		masterPanel.draw();	
    	}
    
    	 public VLayout testCase11() {  
    		 
        	VLayout test = new VLayout();
        	test.setWidth100();
        	test.setHeight100();		 			  
        	
        	MyCheckBoxEditor editor =  new MyCheckBoxEditor();
        	editor.setDataPath("checkBoxField1/booleanValue");
    	    
            DataSourceField pkField = new DataSourceField();
            pkField.setName("primaryKey");
            pkField.setType(FieldType.SEQUENCE);
            pkField.setPrimaryKey(true);
            pkField.setHidden(false);
    	
    	    DataSourceField myCheckBoxField = new DataSourceField();   
    	    myCheckBoxField.setName("checkBoxField1");   
    	    myCheckBoxField.setTitle("checkBoxField1");   
    	    myCheckBoxField.setType(new MyCheckBoxType());   
    	    myCheckBoxField.setEditorType(editor);
    		    
    		JavaScriptObject jsObject = JSOHelper.createObject();
    		JSOHelper.setAttribute(jsObject, "booleanValue", Boolean.FALSE);
    	    
            ListGridRecord[] result = new ListGridRecord[1];
            result[0] = new ListGridRecord();
            result[0].setAttribute("checkBoxField1", jsObject);
            result[0].setAttribute("primaryKey", 1);
            
            DataSource dataSource = new DataSource();
            dataSource.setID("testDS");
    	    dataSource.setFields(pkField, myCheckBoxField);   
    	    dataSource.setClientOnly(true);
    	    dataSource.setTestData(result);	    
      
    	    //the order list grid   
    	    final DynamicForm form = new DynamicForm();   
    	    form.setHeight(170);   
    	    form.setWidth(500);
    	    form.setDataSource(dataSource);
    	    form.setAutoFetchData(true);//!!!
    	    
    	    final ListGrid grid = new ListGrid();
    	    grid.setEditByCell(true);
    	    grid.setShowAllRecords(true);
    	    grid.setHeight(170);   
    	    grid.setWidth(500);
    	    grid.setCanEdit(true);
    	    grid.setDataSource(dataSource);
    	    grid.setAutoFetchData(true);//!!!
    	    grid.setShowRowNumbers(false);
    	    	    
    	    Button showRowNumbers = new Button("show row numbers");
    	    showRowNumbers.addClickHandler(new ClickHandler() {
    			
    			public void onClick(ClickEvent event) {
    				if(!grid.getShowRowNumbers()){
    					grid.setShowRowNumbers(true);
    					grid.refreshFields();
    				}		
    				else{
    					grid.setShowRowNumbers(false);
    					grid.refreshFields();
    				}
    			}
    		});
    
    	    test.addMember(grid);	    
    	    test.addMember(showRowNumbers);
    	    test.addMember(form);
    	    return test;
    	}
    
    }
    
        public static class MyCheckBoxType extends SimpleType {   
            public MyCheckBoxType() {   
                super("myCheckBoxType", FieldType.BOOLEAN);   
     
            }   
        }  
        
        private class MyCheckBoxEditor extends CheckboxItem {
    
        	public MyCheckBoxEditor() {
        		super();
        		this.setAllowEmptyValue(true);
        		this.setShowUnsetImage(true);    
        	}    	
        }
    Last edited by bade; 4 Apr 2011, 06:01.

    #2
    This test case is still trying to use an Object containing a boolean as the value for a boolean field. Haven't we explained sufficiently that this is a dead end (at least, it's a dead end without major features being added to support it first).

    Comment


      #3
      Excuse me?!?

      Might I remind you of the following:

      http://forums.smartclient.com/showthread.php?t=15683

      Originally posted by Isomorphic
      Yes, that approach is fine. The underlying value needs to be a Boolean, so if there's a Boolean value somewhere and it's reachable via dataPath, that works.
      What didn't I understand correctly?!?

      Comment


        #4
        It's fine for a FormItem for a limited case of just editing the value.

        However as we discussed here, the overall approach of storing special objects instead of normal atomic values has serious issues in filtering, sorting, and many other areas.

        So there seems to be little point in pursuing getting this approach working for just editing.

        Comment


          #5
          Just to clarify further, there's two different use cases that have been discussed:

          1. if you're still trying to make your own boolean-like SimpleType which is represented by a custom object, and expecting that sorting/filtering/summing etc can be made to work, this won't work without feature sponsorship to add a bunch of features to allow all these operations to work with a custom object instead of a normal atomic type (as previously discussed). So this is what we're telling you is a dead end approach.

          2. if you're just trying to edit a boolean field in some kind of subobject where your expectation is that sorting/filtering/summing/etc will *not* just transparently work, that's fine and is what dataPath is meant to do. But if so, then please clarify what's going wrong so we know you have the right expectations: what do you mean by "correctly set (interpreted)"?

          Comment


            #6
            The case that I was addressing here is that I thought there was something wrong with the dataSource.setTestData(result);

            Why? Because I CAN use my custom simple type boolean in our app (using the datapath) and it works both in grid and form (including editing). So, imagine my suprise by your reactions on this test case?!?

            That being said, I didn't get from your post that using dataPath doesn't support editing in grid?
            I was under the impression that if you use dataPath MAPPED to an underlying atomic value we would be back on the supported smart GWT approach AND stuff like sorting, summing would all work?!?
            I mean, I'm kinda supprised that dataPath doesn't support this?
            If you map your value to an atomic type is it that hard to believe that I would think it would work?

            Anyway, it's good that you pointed this out now, because I was going to rework the custom combobox to work with dataPath as well.

            Keep in mind that the post you mentioned was AFTER the post I'm mentioning.

            Secondly I want to clarify the following: What you call a dead end approach is just us getting to the bottom of your framework and figuring out where we might need further support.

            I am fully aware, because of our second discussion, that our custom types (which weren't using dataPath) won't work automagicaly with sorting and summing. But that isn't stopping us from figuring out what can be used.
            Moreover, sorting is working for all our types (except for combobox), required field validation is also working client-side, thanks to the custom validators.
            Filtering is an issue.

            I hope this clears the air a bit and let me know what you think.

            Regards,
            Bart

            Comment


              #7
              dataPath is for displaying and editing a complex nested structure. It's capabilities are similar to a SimpleType in that respect: it wouldn't be expected to make sorting & filtering work, for example.

              The set of enhancements needed to make either SimpleType or dataPath a complete replacement for a normal atomic field value is the same: anywhere any UI component accesses a field value, that component would need to be aware of a possible dataPath or SimpleType definitions that affect what value should be used in whatever operation is being performed.

              Comment


                #8
                Alright, that's clear.
                Could you still take a look at the standalone test case?
                This way I can go and make a testcase of the real issue we are encountering.

                Regards,
                Bart
                Last edited by bade; 7 Apr 2011, 22:42.

                Comment


                  #9
                  Hi,

                  Were you guys able to reproduce the issue?

                  Regards,
                  Bart

                  Comment


                    #10
                    We see the behavior - we'll come back with more info shortly.

                    Comment


                      #11
                      The javascript exception is being thrown due to the fact that while the field has a data-path, the dataPath doesn't actually resolve to a nested dataSource field.
                      The expected usage here is basically that you have nested dataSources and then dataPath on some component field allows you to reach into them.

                      However, we shouldn't be JS-error'ing when we encounter a dataPath and can't find an associated field/nested dataSource. This was a bug which we've now fixed in our framework.

                      On top of that there were a couple of other things going on here:
                      - you were specifying dataPath on the editorProperties for the field. This effects the formItem directly, and it effects the form item when the listGrid is in edit mode, but it won't make the ListGrid field when not in edit mode aware of the dataPath.
                      We've added a 'ListGridField.setDataPath()' API so you can resolve that.

                      - there was an issue where in development mode a native GWT issue was causing the true (checked) image to show up when the value was actually false. We've worked around this.

                      In short, try the next nightly on this standalone test case (and be sure to set the ListGridField dataPath) and you should see things behaving better - hopefully that will help make sense of the issues in your live app.

                      Comment

                      Working...
                      X