Announcement

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

    saveAllEdits() bug ?

    Hi there,

    version2.4

    Programatically editing records of a ListGrid and calling saveAllEdits() after seems to be buggy. When editing manually (click on cell and keyboard edit) it works well, here is the code i use to simulate this user edition :

    Code:
    private void setSelection(ImgButton buttonClicked, String buttonId) {
    
    		ListGridRecord[] records = getAcquisitionsGrid().getRecords();
    		Log.info("Looking for "+buttonId +" in " + records.length + " records");
    		int idx = -1;
    		Boolean editing = getAcquisitionsGrid().startEditing();
    		if (!editing)
    			Log.error("Not editing for some reason...");
    			
    		for (ListGridRecord record : records) {
    			idx++;
    			if ( record.getAttributeAsString("name").equalsIgnoreCase(buttonId) ){
    				boolean checked = buttonClicked.isSelected();
    				Log.debug(record.getAttributeAsString("name") + " equals ? " + buttonId );
    				Log.debug("edit col "+getAcquisitionsGrid().getEditCol());
    				getAcquisitionsGrid().setEditValue(idx, selectionProperty, checked);
    			
    				if (checked)
    					getAcquisitionsGrid().selectRecord(record);
    				else
    					getAcquisitionsGrid().deselectRecord(record);			
    				
    				break;				
    			} else {
    				continue;
    			}
    				
    		}
    		getAcquisitionsGrid().endEditing();
    		int[] rows = getAcquisitionsGrid().getAllEditRows();
    		Log.info("Edited rows : " +rows.length);
    	}

    calling saveAllEdits() after that do not include my programatically edited rows, and return false, event if getAllEditRows() returns a correct value.

    Can you please help ?
    Last edited by munger; 29 Jun 2011, 07:48.

    #2
    We have no other reports of problems with saving programmatically applied editValues, and the problem is most likely not in this code but elsewhere. If you think there's a bug, work toward creating a minimal test case that we can run.

    Comment


      #3
      Thanks a lot ISomorphic for your answer.
      Then you think my records should be updated as soon as i execute saveAllEdits after this snippet ?

      Is there any other action i am missing in order to simulate a "manual" edition (which currently works) ?

      Thanks a lot

      Comment


        #4
        saveAllEdits() is asynchronous. If the save was successful, the changes will be present in the records when the callback fires.

        Comment


          #5
          thanks,

          what i mean is that a "update" REST request should be fired as soon as i call saveAllEdits() after this code right ?

          and it is not, even if some records are seen as "edited"

          is there a way to mark the record as "edited" ?

          Thank you

          Comment


            #6
            Ok, the problem seems to be with boolean fields only.

            In the code snippet above, if the type of field selectedProperty is boolean, the problem occurs, adding a new line changing another value (of type String), makes it work !

            The problem seems to be that boolean fields are not considered as edited even if changed with method setEditValue()

            Could you check please ?



            code that works, just a new line added
            Code:
            getAcquisitionsGrid().setEditValue(idx, "barcode", idx +"000" +idx);
            makes the update to be fired properly when calling saveAllEdits()


            Code:
            boolean checked = buttonClicked.isSelected();
            				Log.debug(record.getAttributeAsString("name") + " equals ? " + buttonId);
            				Log.debug("edit col " + getAcquisitionsGrid().getEditCol());
            				getAcquisitionsGrid().setEditValue(idx, selectionProperty, checked);
            				getAcquisitionsGrid().setEditValue(idx, "barcode", idx +"000" +idx);
            				if (checked)
            					getAcquisitionsGrid().selectRecord(record);
            				else
            					getAcquisitionsGrid().deselectRecord(record);

            Comment


              #7
              If there are changes, saveAllEdits() will immediately issue save requests for any records that pass client-side validation.

              If you think you've got a bug, prepare a minimal, standalone test case we can run to see the problem.

              Comment


                #8
                Yes i am quite confident that changes of boolean values are not detected properly to issue update requests towards server side, even if changed.
                I'll try to make a test case for you.
                Thanks!

                Comment


                  #9
                  It appears quite difficult to debug finally, sometimes the saveAllEdits() method returns false, i have no idea why.
                  What are the most common reasons for a save to fail ?

                  Comment

                  Working...
                  X