Announcement

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

    ClassFactory.addGlobalID: ID:'isc_SelectItem_XX' collisions

    I'm still trying to build a standalone test case, but there's a lot going on here and I'd hoped to pare it down to something more manageable before I post it.

    For now, I'll say that I have 2 tabs. One with a form and one with a ListGrid. The form gets its fields collection from the result of some fetch operation, and looks something like this:

    Code:
    ds.fetchData(criteria, new DSCallback() {
    		@Override
    		public void execute(DSResponse response, Object rawData, DSRequest request) {
    			
    			ArrayList<String> attributes = new ArrayList<String>();
    			ArrayList<FormItem> items = new ArrayList<FormItem>();
    
    			for (int i=0; i<response.getData().length; i++) {
    				Record rec = response.getData()[i];
    				String attributeName = "attr" + rec.getAttribute("id");
    				attributes.add(attributeName);
    				FormItem item = new FormItem(attributeName);
    				item.setWidth(150);
    				items.add(item);
    			}
    			form.setFields(items.toArray(new FormItem[0]));
    			getRelatedEditor().setGridFields(attributes);
    		}
    	});
    }
    where getRelatedEditor's setGridFields method does pretty much what it sounds like:

    Code:
    void setGridFields(List<String> attributes) {
    
    		final ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
        
    		/*
    		 * always add these 2 fields, but the rest are determined dynamically
    		 */
    		ListGridField color = new ListGridField(ProductionLineVariant.ITEM_COLOR);
    		color.setValueMap(IPGui.getValueMapFromRecords(IPGui.getColorRecords(), IPCOLOR.CCLR, IPCOLOR.CLRN));
    		color.setCanEdit(false);
    
    		ListGridField size = new ListGridField(ProductionLineVariant.ITEM_SIZE);
    		size.setValueMap(IPGui.getValueMapFromRecords(IPGui.getSizeRecords(), IPSIZES.SSIZ, IPSIZES.SNAM));
    		size.setCanEdit(false);
    
    		fields.add(color);
    		fields.add(size);
    
    		for (String attr : attributes) {
    			ListGridField field = new ListGridField(attr);
    			field.setAttribute("detail", false);
    			fields.add(field);
    		}
    		
    		grid.setFields(fields.toArray(new ListGridField[]{}));
    		grid.invalidateCache();
    }
    Each of the dynamic fields in this case has a valueMap defined on it by way of a (dynamic) datasource. This all works fine, except that when I double click a grid row to startEditing, I'm greeted with a bunch of log entries like

    Code:
    [ERROR] [ipgui] - 10:54:42.927:MUP7:WARN:Log:ClassFactory.addGlobalID: ID:'isc_SelectItem_59' for object '[SelectItem ID:isc_SelectItem_59 name:attr40]' collides with ID of existing object '[SelectItem ID:isc_SelectItem_59 name:attr01]'. The global reference to this object will be replaced
    at which time either the formItem's valueMaps are unusable or the listGridField's are. Which is affected seems to be pretty arbitrary. Each attempt to edit yields something like this in the log

    Code:
    11:16:18.602:IFCS8:WARN:nativeFocus:isc_SelectItem_93[attr35]:calling element.blur() to correct focus in hidden item: [SelectItem ID:isc_SelectItem_93 name:attr35]
    As I said, there's a lot going on here. I'm hoping that the minimal code & log output I've shown here is enough to put us on the right track. If not, I'm happy to post the entire contents of the log, but I'd ask for some guidance regarding log levels and where you think I should start and end it.

    Thanks in advance.

    Edit: I don't necessarily see how it's relevant, but I'll also mention that form and grid use different datasources having these dynamic fields in common.
    Last edited by bbruyn; 20 Aug 2012, 10:44. Reason: Forgot to mention that the form and grid use different datasources

    #2
    What it seems to be is that in fact the generated FormItems are being given colliding IDs...

    In the first code snippet you go through the trouble of putting together a list of attributes:

    Code:
    ArrayList<String> attributes = new ArrayList<String>();
    .. but we don't seem what ends up happening to this variable. It's likely that this or some other data derived from the server's returned data ends up as a call to setAttribute("ID", ..) with an ID value that hasn't been made unique.

    Comment


      #3
      Originally posted by Isomorphic View Post
      What it seems to be is that in fact the generated FormItems are being given colliding IDs...
      Okay, I deserved that.

      In the first code snippet you go through the trouble of putting together a list of attributes:

      Code:
      ArrayList<String> attributes = new ArrayList<String>();
      .. but we don't seem what ends up happening to this variable.
      It's in the last line of the snippet:

      Code:
      getRelatedEditor().setGridFields(attributes);
      which is what gets handed in to the 2nd snippet. It just contains a List of Strings like "attr01", "attr02" and so on.

      It's likely that this or some other data derived from the server's returned data ends up as a call to setAttribute("ID", ..) with an ID value that hasn't been made unique.
      [/quote]

      A call to setAttribute on what? The FormItem? No, they're given names like attr01, attr02 (which are of course the same on both tabs) but no ID is set explicitly - you can see that in the snippet...

      The ID it seems to be complaining about takes the form 'isc_SelectItem_XX', which as far as I know is generated by the framework.

      Comment


        #4
        Ah, OK, we see the handling of attributes.

        Whatever the problem is, we suspect it's not in the code you've shown so far. One thing that could create ID collisions, but which does not appear to be done in this part of the code, would be to take a FormItem and provide it to two different forms, a form and grid (the latter via setEditorType()), or even the same form via two calls to setItems().

        Also, just for paranoia sake, try removing the calls to ArrayList.toArray(). These should be perfectly safe but possibly you are hitting a core GWT bug.

        Comment

        Working...
        X