Hello:
This my first question in this forum. I am new smartgwt developer and I have a lot of questions. But I write only to ask about one problem.
I have to do a validation when a listgrid cell changes. The validation is that can't exist the same value in the column twice.
The code is this:
The found behaivour is that the cell doesn't show the error and the cell doesn't allow write the same value twice.
What am I doing wrong?
This my first question in this forum. I am new smartgwt developer and I have a lot of questions. But I write only to ask about one problem.
I have to do a validation when a listgrid cell changes. The validation is that can't exist the same value in the column twice.
The code is this:
Code:
ListGridField itemIdField = new ListGridField("itemId", RECTIFICATIONS_MESSAGES.fieldItemId()); itemIdField.setRequired(true); itemIdField.setCanEdit(true); itemIdField.setType(ListGridFieldType.INTEGER); IntegerRangeValidator itemIdRange = new IntegerRangeValidator(); itemIdRange.setMin(0); itemIdRange.setMax(999999); itemIdField.setValidators(itemIdRange); itemIdField.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { GWT.log("OnChanged " +event.getValue().getClass().getName()); String value = event.getValue().toString(); String field_name = getFieldName(event.getColNum()); GWT.log("fieldName : " + field_name); Record[] records = getRecordList().findAll(field_name, value); int times = (records == null) ? 0 : records.length; if (times != 0){ String error_msg = "No se puede poner el item " + value + " " + times + " veces ."; setFieldError(event.getRowNum(),field_name,error_msg); refreshCell(event.getRowNum(), event.getColNum()); refreshRecordComponent(event.getRowNum(), event.getColNum()); refreshRow(event.getRowNum()); refreshRecordComponent(event.getRowNum()); redraw(); GWT.log(error_msg); } } });
What am I doing wrong?