SmartGwt 6.1p
Hi
I have a completely dynamically created ListGrid and Datasource based on csv string, but without connecting the datasource component to the .ds.xml file.
ListGrid presents the user with data that will be imported into the database into various tables depending on the definition of columns in csv. One of the columns is the username that I want to verify with the database using the validator. Here my problem arises because if the definition of using the validator in the .ds.xml file is not a problem then my form design does not provide such a file (due to the dynamic structure of the csv file) and I create everything by hand.
I am asking for advice on how to connect a CustomServer validator running on ListGrid and DataSource in the ClientOnly (true) and SaveLocaly (true) mode from the java code level. I am currently trying to do something like this but it does not work:
listGrid_Wyniki.setID("ListGrid_Wyniki");
listGrid_Wyniki.setAutoFetchData(false);
listGrid_Wyniki.setSaveLocally(true);
listGrid_Wyniki.setAutoSaveEdits(false);
listGrid_Wyniki.setSaveByCell(false);
listGrid_Wyniki.setWidth100();
listGrid_Wyniki.setHeight100();
listGrid_Wyniki.setCanEdit(true);
listGrid_Wyniki.setCanSort(false);
listGrid_Wyniki.setAutoFitFieldWidths(true);
listGrid_Wyniki.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
listGrid_Wyniki.setCanRemoveRecords(false);
listGrid_Wyniki.setLayoutAlign(Alignment.CENTER);
listGrid_Wyniki.setValidateByCell(true);
listGrid_Wyniki.setValidateOnChange(true);
listGrid_Wyniki.setShowRowNumbers(true);
listGrid_Wyniki.setCanSelectCells(true);
listGrid_Wyniki.setFilterLocalData(true);
listGrid_Wyniki.setUseRemoteValidators(true);
dataSource_rsTempImpCSV = new DataSource();
dataSource_rsTempImpCSV.setClientOnly(true);
Record[] recordsCSV = dataSource_rsTempImpCSV.recordsFromText(str_csv, settings);
RecordList recordList = new RecordList(recordsCSV);
listGrid_Wyniki.setDataSource(dataSource_rsTempImpCSV);
listGrid_Wyniki.setData(recordList);
Próbuję podłączyć validację jednej kolumny z bazą danych:
CustomValidator impWynBad_Validator = new CustomValidator() {
@Override
protected boolean condition(Object value) {
setType(ValidatorType.SERVERCUSTOM);
setAttribute("serverObject", "lookupStyle="new" className="pl.ciop.pbf.server.validators.rs.ValidatorDMI" methodName="isKodBadanego"");
setAttribute("errorMessage", "$errorMessage");
return false; //I now this is bad but :/
}
};
impWynBad_Validator.setClientOnly(false);
impWynBad_Validator.setErrorMessage("no rec value in db!");
impWynBad_Validator.setValidateOnChange(true); listGrid_Wyniki.getField("OS_KOD_BADANY").setValidators(impWynBad_Validator);
Thank you for any help and I apologize for my poor English.
Hi
I have a completely dynamically created ListGrid and Datasource based on csv string, but without connecting the datasource component to the .ds.xml file.
ListGrid presents the user with data that will be imported into the database into various tables depending on the definition of columns in csv. One of the columns is the username that I want to verify with the database using the validator. Here my problem arises because if the definition of using the validator in the .ds.xml file is not a problem then my form design does not provide such a file (due to the dynamic structure of the csv file) and I create everything by hand.
I am asking for advice on how to connect a CustomServer validator running on ListGrid and DataSource in the ClientOnly (true) and SaveLocaly (true) mode from the java code level. I am currently trying to do something like this but it does not work:
listGrid_Wyniki.setID("ListGrid_Wyniki");
listGrid_Wyniki.setAutoFetchData(false);
listGrid_Wyniki.setSaveLocally(true);
listGrid_Wyniki.setAutoSaveEdits(false);
listGrid_Wyniki.setSaveByCell(false);
listGrid_Wyniki.setWidth100();
listGrid_Wyniki.setHeight100();
listGrid_Wyniki.setCanEdit(true);
listGrid_Wyniki.setCanSort(false);
listGrid_Wyniki.setAutoFitFieldWidths(true);
listGrid_Wyniki.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
listGrid_Wyniki.setCanRemoveRecords(false);
listGrid_Wyniki.setLayoutAlign(Alignment.CENTER);
listGrid_Wyniki.setValidateByCell(true);
listGrid_Wyniki.setValidateOnChange(true);
listGrid_Wyniki.setShowRowNumbers(true);
listGrid_Wyniki.setCanSelectCells(true);
listGrid_Wyniki.setFilterLocalData(true);
listGrid_Wyniki.setUseRemoteValidators(true);
dataSource_rsTempImpCSV = new DataSource();
dataSource_rsTempImpCSV.setClientOnly(true);
Record[] recordsCSV = dataSource_rsTempImpCSV.recordsFromText(str_csv, settings);
RecordList recordList = new RecordList(recordsCSV);
listGrid_Wyniki.setDataSource(dataSource_rsTempImpCSV);
listGrid_Wyniki.setData(recordList);
Próbuję podłączyć validację jednej kolumny z bazą danych:
CustomValidator impWynBad_Validator = new CustomValidator() {
@Override
protected boolean condition(Object value) {
setType(ValidatorType.SERVERCUSTOM);
setAttribute("serverObject", "lookupStyle="new" className="pl.ciop.pbf.server.validators.rs.ValidatorDMI" methodName="isKodBadanego"");
setAttribute("errorMessage", "$errorMessage");
return false; //I now this is bad but :/
}
};
impWynBad_Validator.setClientOnly(false);
impWynBad_Validator.setErrorMessage("no rec value in db!");
impWynBad_Validator.setValidateOnChange(true); listGrid_Wyniki.getField("OS_KOD_BADANY").setValidators(impWynBad_Validator);
Thank you for any help and I apologize for my poor English.
Comment