Announcement

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

    ListGrid errors subsequent row errors don't display.

    I am creating a tree grid and I perform server-side validation that I set the errors in the database so that when the users fetches the data again the errors will show on the field again. I do this on fetch by on the server returning an error array of fieldname:{errormessages} per JSON row object. The fetch code handles these as such:

    Code:
    fetchData(null, new DSCallback() {
    	@Override
    	public void execute(DSResponse response, Object rawData, DSRequest request) {
    		for(Record r:response.getData()) {
    			JSONArray errors = XMLTools.selectObjects(r.getJsObj(), "errors");
    			HashMap<String, String[]> es = new HashMap<String, String[]>();
    			for(int e=0;e<errors.size();e++){
    				JSONObject error = errors.get(e).isObject();
    				for(String key:error.keySet()) {
    					JSONArray ers = error.get(key).isArray();
    					String msgs[] = new String[1];
    					if(ers != null) {
    						msgs = new String[ers.size()];
    						for(int m=0;m<ers.size();m++) {
    							msgs[m] = ers.get(m).isString().stringValue();
    						}
    					} else
    						msgs[0] = error.get(key).toString();
    					es.put(key, msgs);
    				}
    			}
    			setRowErrors(getRecordIndex(r), es);
    		}
    	}
    
    });
    This seems to work in that the fields are marked with the exclamation point icon. However on mouse over only the first field with an error in a row popups the message the others in the same row don't show the error.

    #2
    What are you trying to accomplish here, in terms of the bigger picture? Do you know that the Enterprise Edition already contains a component for Batch Upload of records that need to go through validation?

    Can you explain your use case in more detail (we might recommend a completely different approach from what you've started on), and also perhaps show a screenshot of where you are/are not seeing hovers or error messages?

    Comment


      #3
      There is a tree grid that stores a list of parts that are related to one another. This is a databound TreeGrid. When users interact with the data the validation errors need to be stored in the database so that other users will see them. So on fetch the errors are returned with the rows if the exist and then set using the setRowErrors method. However, you will see in the first attachemnt that the first field with an error shows the error on mouse over, but in the second attachment any other field errors are marked but no error shows up on mouse over.

      Thank you!
      Attached Files

      Comment


        #4
        OK, generally making a one-time call to show errors like that has lots of problems. The issue is, when should the error be discarded? When the cell is edited? What if the error involves more than one field? Should all errors be cleared if the save is successful?

        By instead providing validators that will actually return these errors if they are still present, you define a clear lifecycle for the errors, since the framework can always just run the validator to see if the error is still there.

        If instead you want to step outside of the normal validation system completely, don't use setRowErrors(), instead use generic formatting APIs like CellFormatters and getValueIcon() to show the errors. You can then control the lifecycle of the errors directly by just changing the data you've loaded into the grid and calling refreshRow() to have your formatting APIs called and the row re-rendered.
        Last edited by Isomorphic; 17 Nov 2010, 17:48.

        Comment

        Working...
        X