Announcement

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

    Possible Bug with canEdit

    SNAPSHOT_v9.1d_2013-10-17/PowerEdition Deployment (built 2013-10-17)

    We are seeing what we think is a bug in calling canEdit() that only seems to present itself in fully deployed environments and not in development mode.

    We have our own custom IpListGrid, which extends ListGrid. The instance in question has a context menu where clicking the menu items fails without returning any errors.

    By tracing through the Javascript, we see that the menu items' click handlers make calls to a method that belongs to IpListGrid, which begins as follows:

    Code:
    public void editSelectedRecords(final EditSelectedRecordsCallback callback, final Boolean skipSaveAll) {
    		// Count the records that have at least one editable field.
    		// Build a list of selected rows that cannot be edited so we can de-select them.
    		RecordList rowsToDeselect = new RecordList();
    		int rowCountToUpdate = 0;
    		for (int s=0; s<getSelectedRecords().length; s++) {
    			ListGridRecord selectedRecord = getSelectedRecords()[s];
    			int rowNum = getRecordIndex(selectedRecord);
    			boolean canEditRow = false;
    			for (int colNum=0; colNum<getFields().length; colNum++) {
    				if (canEditCell(rowNum, colNum)) {
    					canEditRow = true;
    					rowCountToUpdate += 1;
    					break;
    				}
    			}
            .
            .
            .
            etc...
    You will see that in this method we make a call to canEditCell(). When I trace through the JavaScript I see that when we call canEditCell() the code goes through some hoops and ends up trying to make a call to the __canEditCell(() method on our object.

    However, this method does not exist, whereas canEditCell() (i.e., without the double underscore prefix) does. Looking further, we see that the prior call to getSelectedRecords() is called in a similar fashion, but correctly omits the double underscore prefix.

    I have attached an image of the Chrome debugger showing the point at which the failure occurs. In that image you will see that c.canEditCell() resolves correctly, whereas c.__canEditCell() is unresolved.

    Is this enough information for you to identify whether or not there is an issue here?

    Thanks,
    Gary O'Donnell
    Attached Files

    #2
    Just one thing to add. This same code works in the prior version of SmartGWT we were running. SmartClient Version: v8.3p_2013-09-26/PowerEdition Deployment (built 2013-09-26). So this appears to be regression with the new release.

    Comment


      #3
      How is your listGrid actually created? In standard Java code, or something else like being part of a loaded XML view?
      Can you show us what your override class looks like, and what your code to create the instance looks like? We may ultimately need a standalone test case but these 2 things may give us enough to go on

      Thanks
      Isomorphic Software

      Comment


        #4
        We create the ListGrid within Java code. The override class itself is almost 2500 lines, so I'm not sure you want or need that much detail. I'll see if I can work up a smaller test case - if I can eliminate our override class altogether, so much the better.

        I thought, though, the constructor might be of interest/use to you, so here it is:

        Code:
        	public IpListGrid(String componentName) {
        
        		super();
        		setLeaveScrollbarGap(false);
        		setAttribute("useAdvancedFieldPicker", true, false);
        		setAttribute("advancedFieldPickerThreshold", 10, false);
        		
        		myComponentName = componentName;
        		setCanAddFormulaFields(true);
        
        		// When filter editor is changed, save criteria into a cookie.
        		addFilterEditorSubmitHandler(new FilterEditorSubmitHandler() {
        
        			@Override
        			public void onFilterEditorSubmit(FilterEditorSubmitEvent event) {
        				if (event.getCriteria().getJsObj()==null)
        					Cookies.removeCookie(getCriteriaCookieName());
        				else
        					Cookies.setCookie(getCriteriaCookieName(), 
        							JSON.encode(event.getCriteria().getJsObj()), 
        							IPGui.COOKIE_EXPIRES);
        			}
        		});
        
        		// When grid is drawn, set filter editor criteria from cookie.
        		addDrawHandler(new DrawHandler() {
        			@Override
        			public void onDraw(DrawEvent event) {
        				
        				// Restore any filter criteria that may have been previously saved.
        				if (Cookies.getCookie(getCriteriaCookieName())!=null) {
        					Criteria criteria = new Criteria(JSON.decode(Cookies.getCookie(getCriteriaCookieName())));
        					setFilterEditorCriteria(criteria);
        				}
        				// Set prompt on field to show full field title.
        				for (ListGridField field : getFields()) {
        					if (field.getPrompt()==null || field.getPrompt().isEmpty()) {
        						field.setPrompt(field.getTitle());
        					}
        				}
        				refreshFields();
        				loadGridSettingsForCurrentUser();
        			}
        		});
        		
        		addDataArrivedHandler(new DataArrivedHandler() {
        			@Override
        			public void onDataArrived(DataArrivedEvent event) {
        				int foo = event.getStartRow();
        				Record r = new Record();
        				if (isGrouped()) {
        					foo++;
        				}
        				if (getRecord(foo) != null) {
        					r = getRecord(foo);
        				}
        				installAdvancedFieldPickerSampleValue(r);
        			}
               });
        		
        		me = this;
        	}
        Thanks,
        Gary O'Donnell

        Comment


          #5
          We have done a bit of investigating on our side and cannot reproduce the issue. Can you please provide a simple test case with which you can produce the issue.

          Comment


            #6
            In creating a standalone test case I discovered the problem has been fixed somewhere between version v9.0p_2013-10-30 and v9.0p_2013-11-14. Updating to the 11/14 build resolved it for us.

            In case you want to investigate further I've attached the test case. I modified the builtinds sample project and added a trimmed down version of our IpListGrid. If you select a datasource, select a few rows in the grid and click the Edit Selected Records button you'll see an edit form appear in a window.

            With the 10/30 build, and in compiled mode only, the window does not appear for the reasons described in the original post. In the 11/14 build the call to canEditCell it works fine and the edit window appears.
            Attached Files

            Comment

            Working...
            X